Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requirement ID and ôinternalö ID

Status
Not open for further replies.

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:
Code:
Dim pmiLabel1 As Annotations.PmiLabel = CType(workPart.FindObject("HANDLE R-6057708"), Annotations.PmiLabel)
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.

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
 
Replies continue below

Recommended for you


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
 
There appears an error. The type „var“ is not defined. How can I fix this?
 
Replace Var with NXOpen.Annotations.Label

Regards,
Mukundh
 
Is your goal to change the text of a PMI label?

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 Module

P.S. In general: journal identifier <> ID

www.nxjournaling.com
 
My goal is to compare each character size of a given PMI element with a fixed value.
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
 
This code should get you started:

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 Module

www.nxjournaling.com
 
Hey cowski, thanks so far!
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 :-( [line 34]
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
 
What version of NX are you using?

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
 
NX Version: 8.0.3.4
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


 
Try changing the for loop as shown below. It won't solve the problem, but it will report more to the info window, which might point you in the right direction.

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

Next

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor