Requirement ID and ôinternalö ID
Requirement ID and ôinternalö ID
(OP)
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





RE: Requirement ID and ôinternalö ID
You can use the below code for non selection.(Replace your Main with below)
Sub Main()
lw.Open()
lw.WriteLine("------------------------------------------")
Dim prefix As String = "HANDLE R-"
For Each label As var In sess.Parts.Work.Labels.ToArray()
Dim jid As String = label.JournalIdentifier.Replace(prefix, "")
lw.WriteLine("Object ID " & jid)
Next
End Sub
Regards,
Mukundh
RE: Requirement ID and ôinternalö ID
RE: Requirement ID and ôinternalö ID
Regards,
Mukundh
RE: Requirement ID and ôinternalö ID
If so, why not loop through the PMI objects until you find the one of interest and change it accordingly?
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() If IsNothing(theSession.Parts.Work) Then 'active part required Return End If Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() lw.WriteLine("num PMIs: " & workPart.PmiManager.Pmis.ToArray.Length.ToString) For Each myPmi As Annotations.Pmi In workPart.PmiManager.Pmis lw.WriteLine("name: " & myPmi.Name) lw.WriteLine("index: " & myPmi.Index.ToString) 'lw.WriteLine("journal identifier: " & myPmi.JournalIdentifier.ToString) 'create PMI builder to edit object 'check existing text 'change text 'etc etc Next lw.Close() End Sub End ModuleP.S. In general: journal identifier <> ID
www.nxjournaling.com
RE: Requirement ID and ôinternalö ID
For example: character size of “Note” should always be 3.0
Of course there are the PMI preferences but during time I cannot assure that for each label the character size is always 3.0. It is quite possible that the size was changed partially, maybe for optical purposes, maybe for other motives. For that reason I simply want to check each label and compare the actual value with a fixed one.
For an advanced version of the checker tool I want to set different comparison values for each of the different PMI elements (such as Note=3.0, Feature Control Frame=4.5, Coordinate Note=3.5 etc.).
With the help of the PMI Report (exported excel file: information -> pmi -> report) all PMI elements are well known. Initially I thought it is possible to read the Requirement ID and the PMI Type column and check the character size of the element in dependence of its PMI type respectively. If any deviation is found the aim is to provide the Requirement ID of this element with the actual “wrong” character size.
I guess it is even easier to find the deviation(s) than returning the corresponding Requirement ID of a “broken” PMI element. As far as I know this is the easiest way to find the specific element again inside the Part Navigator (in addition to the display view name [-> model views]). In general I don’t want to overwrite/change the character size of such an element automatically. It makes more sense for me to log all the deviation(s) but decide on my own if all the divergent sizes have to be adapted. Usually there are some elements which simply “deserve” a divergent size.
Regards,
Polynom3000
RE: Requirement ID and ôinternalö ID
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module2 Sub Main() Dim theSession As Session = Session.GetSession() If IsNothing(theSession.Parts.Work) Then 'active part required Return End If Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() lw.WriteLine("num PMIs: " & workPart.PmiManager.Pmis.ToArray.Length.ToString) For Each myPmi As Annotations.Pmi In workPart.PmiManager.Pmis lw.WriteLine("name: " & myPmi.Name & "(" & myPmi.Index & ")") 'lw.WriteLine("index: " & myPmi.Index.ToString) 'lw.WriteLine("type: " & myPmi.GetType.ToString) Dim dispInst() As Annotations.Annotation = myPmi.GetDisplayInstances For Each thisDispInst As Annotations.Annotation In dispInst 'lw.WriteLine("instance type: " & thisDispInst.GetType.ToString) If TypeOf (thisDispInst) Is Annotations.GeneralNote Then Dim generalNoteBuilder1 As Annotations.GeneralNoteBuilder generalNoteBuilder1 = workPart.PmiManager.PmiAttributes.CreateGeneralNoteBuilder(thisDispInst) If generalNoteBuilder1.Style.LetteringStyle.GeneralTextSize <> 3 Then lw.WriteLine("** text size: " & generalNoteBuilder1.Style.LetteringStyle.GeneralTextSize.ToString) End If generalNoteBuilder1.Destroy() End If Next lw.WriteLine("") Next lw.Close() End Sub End Modulewww.nxjournaling.com
RE: Requirement ID and ôinternalö ID
I guess there might be a slight error in the provided code.
Line 33: Comparing the actual character size
The character size of one sample note (instance type: NXOpen.Annotations.PmiNote) in my file is 4.0 for sure. After running the code there appears no extra line in the information window
Probably there is something wrong with the If command?
In order to separate the different instance types (different character sizes) I want to replace line 29 and compare each instance type with the different cases the program should examine (select case var, var -> different instance types with different allowed character sizes).
With the help of the PMI builder for each different case (PmiNote, PmiLabel, CoordinateNote, …) you obviously want to get the actual character size.
In line 30 Annotations.GeneralNoteBuilder is called. Is this declaration valid for ALL the other PMI build purposes (like CoordinateNote, PMI feature control frame, …) because I cannot find any other ~builder?
Same thoughts in line 31: .CreatePmiNoteBuilder
Thank you for your support!
The goal is close
Best regards,
Polynom2000
RE: Requirement ID and ôinternalö ID
The code above only checks PMI objects of type "general note" and it only checks the general text size (you can also check the appended text size, dimension text size, and tolerance text size). It was only provided as illustration and not as a complete coded solution.
Can you post a sample file with several different PMI objects you would like to check? The bundle I currently have access to doesn't have a full PMI license, so all I can create are general notes...
www.nxjournaling.com
RE: Requirement ID and ôinternalö ID
I was looking for the general text size only, so the result is confusing…
I am very sorry, but I am not allowed to upload any file from my computer.
Does Siemens provide any further information or documentation about this specific PMI subject?
Best regards,
Polynom2000
RE: Requirement ID and ôinternalö ID
CODE
For Each thisDispInst As Annotations.Annotation In dispInst lw.WriteLine("instance type: " & thisDispInst.GetType.ToString) If TypeOf (thisDispInst) Is Annotations.GeneralNote Then Dim generalNoteBuilder1 As Annotations.GeneralNoteBuilder generalNoteBuilder1 = workPart.PmiManager.PmiAttributes.CreateGeneralNoteBuilder(thisDispInst) lw.WriteLine("current general text size: " & generalNoteBuilder1.Style.LetteringStyle.GeneralTextSize.ToString) If generalNoteBuilder1.Style.LetteringStyle.GeneralTextSize <> 3 Then lw.WriteLine("** text size: " & generalNoteBuilder1.Style.LetteringStyle.GeneralTextSize.ToString) End If generalNoteBuilder1.Destroy() End If Nextwww.nxjournaling.com