Getting a point on a NURBS surface for given params
Getting a point on a NURBS surface for given params
(OP)
Hi
I am creating a surface using a thru curves option UF_MODL_create_thru_curves. I need to get a point on this surface for a given u and v parameter values. How can this be done ?
Thanks for the help.
Regards
Wilson





RE: Getting a point on a NURBS surface for given params
CODE
www.nxjournaling.com
RE: Getting a point on a NURBS surface for given params
Cowski, thanks for the reply.
I see there is no straight way to create scalar objects as the constructor for those are protected.
I saw this function UF_CALL(UF_POINT_create_on_surface(tGeometry, tag_u, tag_v, PtTag)); to which I need to pass tags to scalar objects for u and v.
It can be done this way (I just recorded a journal in NX and snipped this code)
CODE -->
Part *workPart(m_Session->Parts()->Work()); Expression *expression20; expression20 = workPart->Expressions()->CreateSystemExpressionWithUnits("p1=0.203236403109067", nullUnit); Expression *expression21; expression21 = workPart->Expressions()->CreateSystemExpressionWithUnits("p2=0.159664232702566", nullUnit); Scalar *scalar4; scalar4 = workPart->Scalars()->CreateScalarExpression(expression20, Scalar::DimensionalityTypeNone, SmartObject::UpdateOptionWithinModeling); Scalar *scalar5; scalar5 = workPart->Scalars()->CreateScalarExpression(expression21, Scalar::DimensionalityTypeNone, SmartObject::UpdateOptionWithinModeling); Point *point2; point2 = workPart->Points()->CreatePoint(face1, scalar4, scalar5, SmartObject::UpdateOptionWithinModeling);Is there any straightforward way to create the scalars?
And finally the point is returned through a tag_t. How do I convert it back to a point so that I can see the coordinates ?
RE: Getting a point on a NURBS surface for given params
If you have the tag of an object, you can get the object through the NXObjectManager:
CODE --> VB
The object manager will return an object of type "TaggedObject"; but if I know what type of object I'm asking for, I can create my object accordingly and the API will implicitly cast it to the type I specified. Of course you can perform an explicit cast after you get the tagged object if you prefer not to use implicit type casting.
Below is a VB journal that will allow you to select a B surface and create a point at the 50% U and 50% V location. I'll bet you can translate it to C++ better than I can.
CODE --> VB
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession If IsNothing(theSession.Parts.Work) Then 'active part required Return End If Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Const undoMarkName As String = "NXJ journal" Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName) Dim mySurf As TaggedObject If SelectBsurface("Select B surface", mySurf) = Selection.Response.Cancel Then Return End If 'lw.WriteLine(mySurf.GetType.ToString) Dim mySurfInfo As UFModl.Bsurface theUfSession.Modl.AskBsurf(mySurf.Tag, mySurfInfo) lw.WriteLine("num U poles: " & mySurfInfo.num_poles_u.ToString) lw.WriteLine("num V poles: " & mySurfInfo.num_poles_v.ToString) Dim u As Scalar = workPart.Scalars.CreateScalar(0.5, Scalar.DimensionalityType.None, SmartObject.UpdateOption.DontUpdate) Dim v As Scalar = workPart.Scalars.CreateScalar(0.5, Scalar.DimensionalityType.None, SmartObject.UpdateOption.DontUpdate) Dim theFace As IParameterizedSurface = mySurf Dim uvPoint As Point = workPart.Points.CreatePoint(theFace, u, v, SmartObject.UpdateOption.AfterModeling) uvPoint.SetVisibility(SmartObject.VisibilityOption.Visible) lw.WriteLine(uvPoint.Coordinates.ToString) lw.Close() End Sub Function SelectBsurface(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select a B surface" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim cursor As Point3d Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_b_surface_type .Subtype = 0 End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj, cursor) If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination '----Other unload options------- 'Unloads the image immediately after execution within NX 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately 'Unloads the image explicitly, via an unload dialog 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly '------------------------------- End Function End Modulewww.nxjournaling.com