cancel
Showing results for 
Search instead for 
Did you mean: 

Converting NX Tag to NX Object

Experimenter
Experimenter

How do I convert an NX Tag to an NX Object? 

1 REPLY

Re: Converting NX Tag to NX Object

Siemens Phenom Siemens Phenom
Siemens Phenom

If you have SNAP, then each object type has a "Wrap" function. You pass in the tag, and the Wrap function creates an object of the correct type. Here's an example (in VB) copied from the SNAP Reference Guide:

 

Option Infer On
Imports Snap, Snap.Create

Public Class MyProgram

   Public Shared Sub Main()

      Dim workPart As NXOpen.Part = Snap.Globals.WorkPart.NXOpenPart

      ' Create an NXOpen.Line object     
      Dim startPoint As New NXOpen.Point3d(10, 20, 30)
      Dim endPoint   As New NXOpen.Point3d(100, 150, 300)
      Dim nxopenLine As NXOpen.Line = workPart.Curves.CreateLine(startPoint, endPoint)

      ' Wrap the NXOpen.Line to obtain a Snap.NX.Line
      Dim snapLine As NX.Line = NX.Line.Wrap(nxopenLine.Tag)

      ' Now we can use the Color property of the Snap.NX.Line
      snapLine.Color = System.Drawing.Color.Blue 

   End Sub

End Class

 

 

 

If you're calling NX/Open functions, you use NXOpen.Uitlities. NXObjectManager, like this (in C#):

 

 

 

NXOpen.TaggedObject taggedObject = NXOpen.Utilities.NXObjectManager.Get(tag);

 

 

 

山田
yamada