Polynom3000
Mechanical
- Apr 30, 2014
- 21
Hello community,
I want to extract the “internal” ID of an element with the help of a given requirement ID but don’t know the function behind this task.
Example with a PMI Label:
Requirement ID = 4129
Internal ID = 6057708
The general information window (select element “Label(4129)” inside Part Navigator -> properties) already lists this ID.
Object Dependency Graph:
PMI Label - ID 6057708
With the knowledge of the “internal” ID, I can finally manipulate this PMI Label:
Can I paste “Label(4129)“ or something like that inside the .FindObject() expression to even bypass the “internal” ID?
I have found something similar, but this code forces me to manually select each element of interest. It should be possible to get those “internal” IDs of PMI Labels, Notes etc.
Regards,
Polynom3000
I want to extract the “internal” ID of an element with the help of a given requirement ID but don’t know the function behind this task.
Example with a PMI Label:
Requirement ID = 4129
Internal ID = 6057708
The general information window (select element “Label(4129)” inside Part Navigator -> properties) already lists this ID.
Object Dependency Graph:
PMI Label - ID 6057708
With the knowledge of the “internal” ID, I can finally manipulate this PMI Label:
Code:
Dim pmiLabel1 As Annotations.PmiLabel = CType(workPart.FindObject("HANDLE R-6057708"), Annotations.PmiLabel)
I have found something similar, but this code forces me to manually select each element of interest. It should be possible to get those “internal” IDs of PMI Labels, Notes etc.
Code:
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Module select_by_id
Dim sess As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession
Dim lw As ListingWindow = sess.ListingWindow
Dim wp As Part = sess.Parts.Work
Dim sm As Selection = UI.GetUI.SelectionManager
Sub Main()
lw.Open()
lw.WriteLine("------------------------------------------")
Dim prefix As String = "HANDLE R-"
'Select object, get ID
Dim crv As NXObject = select_element()
If Not crv Is Nothing Then
Dim jid As String = crv.JournalIdentifier.Replace(prefix, "")
lw.WriteLine("Object ID " & jid)
End If
End Sub
Private Function select_element() As NXObject
Dim type_arr() As Selection.SelectionType = {Selection.SelectionType.All}
Dim obj As NXObject = Nothing
Dim cursor As Point3d
Dim sel_resp As Selection.Response = sm.SelectObject("Select an Element", _
"Select Element", Selection.SelectionScope.AnyInAssembly, _
False, type_arr, obj, cursor)
If sel_resp < 4 Then
Return Nothing
Else
Return obj
End If
End Function
End Module
Regards,
Polynom3000