theUFsession.Modl.CreateCurveFromEdge
theUFsession.Modl.CreateCurveFromEdge
(OP)
I am using the subject function to extract the edges from a face of a solid body. Here's the snippet of code:
It works great; however, it is returning the tag of the line. Next I want to take that line and put it on a specific layer.
so, I developed this code from journaling:
I need to convert the tag of the line into an nxobject. How do I do that?
CODE --> vb.net
For Each thisEdge As Edge In largestFace.GetEdges
Dim newCurve As NXOpen.Tag = NXOpen.Tag.Null
theUFsession.Modl.CreateCurveFromEdge(thisEdge.Tag, newCurve)
Next It works great; however, it is returning the tag of the line. Next I want to take that line and put it on a specific layer.
so, I developed this code from journaling:
CODE --> vb.net
Private Sub MoveToLayer(ByVal iLayer As Integer, ByVal obj As NXObject)
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.ApplyToOwningParts = False
displayModification1.NewWidth = DisplayableObject.ObjectWidth.Two
displayModification1.NewLayer = iLayer
'Dim objects1(0) As DisplayableObject
'Dim line1 As Line = CType(workPart.Lines.FindObject("ENTITY 3 24 1"), Line)
'objects1(0) = line1
displayModification1.Apply({obj})
displayModification1.Dispose()
End Sub I need to convert the tag of the line into an nxobject. How do I do that?





RE: theUFsession.Modl.CreateCurveFromEdge
CODE
www.nxjournaling.com
RE: theUFsession.Modl.CreateCurveFromEdge
RE: theUFsession.Modl.CreateCurveFromEdge
That's a matter of opinion. Personally, I don't have a problem with it; especially in cases such as yours. We know that the CreateCurveFromEdge function will return the tag of a curve object. We can do the conversions ourselves, or we can let the compiler do it; I see no advantage to doing it manually.
A tag is just an integer value. The only feasible way to get an object from a tag is through the NXObjectManager. The NXObjectManager.Get() method will return a TaggedObject. So, if you like to do the conversions yourself, you could do something like this (no error checking in the following example):
CODE
www.nxjournaling.com
RE: theUFsession.Modl.CreateCurveFromEdge
CODE --> vb.net
' Find Largest Face from the Face Areas For Each thisEdge As Edge In largestFace.GetEdges Dim newCurve As NXOpen.Tag = NXOpen.Tag.Null Dim newCurveObj As DisplayableObject theUFsession.Modl.CreateCurveFromEdge(thisEdge.Tag, newCurve) newCurveObj = Utilities.NXObjectManager.Get(newCurve) newCurveObj.Layer = 99 NextRE: theUFsession.Modl.CreateCurveFromEdge
www.nxjournaling.com
RE: theUFsession.Modl.CreateCurveFromEdge
CODE --> VB
Public Class MyProgram Public Shared Sub Main() ' Example object for illustration Dim widget = Snap.Create.Widget ' Cycle through edges, creating curves For Each edge In widget.Edges Dim curve = edge.ToCurve curve.Layer = 200 Next End Sub End ClassIf you don't have access to SNAP, you can simplify your code by calling NXOpen.UF.UFObj.SetLayer, rather than using the DisplayModification approach. This SetLayer function receives a Tag as input, so things are easy.