×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

theUFsession.Modl.CreateCurveFromEdge

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:

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

The DisplayModification object only operates on objects of type DisplayableObject. You'll have to get the curve object with the NXObjectManager and cast it to a displayable object. If you are using "Option Strict Off", you can let the compiler do the conversion for you:

CODE

Dim newCurveObj as DisplayableObject = Utilities.NXObjectManager.Get(newCurve) 

www.nxjournaling.com

RE: theUFsession.Modl.CreateCurveFromEdge

(OP)
Isn't that sloppy coding. I was looking for a way to cast a tag into an line or NXobject.

RE: theUFsession.Modl.CreateCurveFromEdge

Quote (EngProgrammer)

Isn't that sloppy coding.

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.


Quote (EngProgrammer)

I was looking for a way to cast a tag into an line or NXobject.

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

Dim newTaggedObj As TaggedObject = Utilities.NXObjectManager.Get(thetag)
Dim newDisplayableObj As DisplayableObject = nothing
newDisplayableObj = CType(newTaggedObj, DisplayableObject) 

www.nxjournaling.com

RE: theUFsession.Modl.CreateCurveFromEdge

(OP)
Still having problems moving the line to a layer. It seems like it moves it but when I turn on that layer there is nothing.

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
        Next 

RE: theUFsession.Modl.CreateCurveFromEdge

Try calling newCurveObj.RedisplayObject() after assigning the new layer. If that doesn't do the job, I'd try saving all the new curves into a list (or array) and using a DisplayModification object to move them all to the new layer.

www.nxjournaling.com

RE: theUFsession.Modl.CreateCurveFromEdge

For comparison, here's how you do it using SNAP functions:

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 Class 

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources