Submitted by danyfer on Thu, 11/07/2013 - 16:19
Forums:
How can I know which of the feature or object have be selected?
I don`t want to use the dialog to select the body,when the user select a body or more,I can get the tag.
How can I know which of the feature or object have be selected?
I don`t want to use the dialog to select the body,when the user select a body or more,I can get the tag.
re: feature or object
Examine the type of what was selected.
In the .net API you can use the .GetType method or TypeOf operator.
Using UF commands, you can get the entity's type and sub-type. Below is some code from GTAC that reports the pre-selected entity's type and sub-type:
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module journal
Sub Main
Dim s As Session = Session.GetSession()
Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
Dim selobj As NXObject
Dim type As Integer
Dim subtype As Integer
Dim lw As ListingWindow = s.ListingWindow
Dim theUI As UI = ui.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
lw.Open()
lw.WriteLine("Selected Objects: " & numsel.ToString())
For inx As Integer = 0 To numsel-1
selobj = theUI.SelectionManager.GetSelectedObject(inx)
ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
lw.WriteLine("Object: " & selobj.ToString())
lw.WriteLine(" Tag: " & selobj.Tag.ToString())
lw.WriteLine(" Type: " & type.ToString())
lw.WriteLine(" Subtype: " & subtype.ToString())
lw.WriteLine("")
Next
End Sub
End Module