Jump to content

Symbol on a NURBS surface

Recommended Posts

How do I place a symbol on a NURBS surface normal to the surface.

Eg. A post on a arched bridge.


I can find the normal vector at the point with vs.EvaluateNurbsSurfacePointAndNormal(surfaceH, u, v)

I assume I can somehow locate the symbol with vs.SetEntityMatrixN( objectHandle, u , v , w,  offset)

How do I get the u,v and w vectors? or calculate the angels from the normal vector to use vs.SetEntityMatrix(vs.LNewObj(), *wp)


I can get it to work with:

        vs.SetWorkingPlaneN(*pt, *norm, *uVec)
        wp = vs.GetWorkingPlane()

        vs.Symbol("post", (0,0), 0)
        vs.SetEntityMatrix(vs.LNewObj(), *wp)


The symbol is placed in document space not the working plane but the GetWorkingPlane function returns the angle in degrees needed for SetEntityMatrix

There must be a better way I am missing...  I am not sure why vs.SetEntityMatrixN needs different inputs to vs.SetWorkingPlaneN


Any pointers appreciated. Thanks


Share this post

Link to post

To follow up the following works:

def placeSymbolOnSurfaceAlignedWithUVDelta(u,v, surfaceHandel, symbolName, du,dv):
	# get the 3d point and vector normal to the surface
	ptExists, pt, normal = vs.EvaluateNurbsSurfacePointAndNormal(surfaceHandel, u, v)
	if ptExists:
		# place the symbol at (0,0,0) then move it. Assumes symbol is defined to be aligned by its insertion point
		vs.Symbol(symbolName, (0,0), 0)
		symbolHandel = vs.LNewObj()
		# create an orientation vector using a point either side of u,v (u-du,v-dv), (u+du,v+dv) where du,dv are small compared to the surface curvature and their relative magnatudes define the orientation in the u,v plane eg u=0,v=0.0001 will result in a vector in the direction of v at the point
		orentation = tuple(map(sub, vs.EvaluateNurbsSurfacePointAndNormal(surfaceHandel, u+du, v+dv)[1], vs.EvaluateNurbsSurfacePointAndNormal(surfaceHandel, u-du, v-dv)[1])) 
		# this is a good estiment but it fails because it is not exactly orthogonal to the normal vector. Correct by projecting onto the plane tangent to the surface at u,v
		uVec = tuple(map(sub,orentation, [vs.DotProduct(orentation,normal)*i for i in normal]))
		# w-vector is the normal vector
		wVec = normal
		# we know the other 2 and they are all orthogonal so v-vector is the cross product of u x w
		vVec = vs.CrossProduct(uVec,wVec)
		# offset is the 3d point because the symbol is currently at 0,0,0
		offsetVec = pt
		vs.SetEntityMatrixN(symbolHandel, uVec, vVec, wVec, offsetVec)
		return symbolHandel


Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...