Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by dane_

  1. 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


  2. 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


  • Create New...