I'm working in team center if this matters.
So I was reading this comment http://nxjournaling.com/comment/5469#comment-5469 and tried to implement it to move my PMI to new layers but I am clearly failing. I have been trying to figure out how to read the NX Open helpfile but its really difficult for me to navigate.
https://docs.plm.automation.siemens.com/data_services/resources/nx/1899/...
Ultimately what I would like this code to do is to find all PMI items in the current work part and then move the first item to layer 20, the second item to layer 21, the third to 22 and so on.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Module MoveTextToLayer
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim Layno As Integer
Dim displayModification1 As DisplayModification
Layno = 20
Dim textObjs As New List(Of DisplayableObject)
For Each temp As Features.Feature In theSession.Parts.Work.Features
If TypeOf (temp) Is Annotations.IPmi Then
Dim myPMI As Annotations.IPmi = temp
textObjs.Add(myPMI)
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.NewLayer = Layno
displayModification1.Apply(textObjs.ToArray)
Layno = Layno + 1
Dim textObjs As New List(Of DisplayableObject)
else
lw.writeline("Item is not of type PMI")
lw.writeline("---------------------------------------------")
End If
Next
displayModification1.Dispose()
End Sub
End Module
Additional Question
Datums and Centerlines are both part of the Annotations.AnnotationManager class but I cant find a class that captures dimensions made in PMI. Is there a class I can use that captures ALL PMI ?
Option Strict Off
Imports System
Imports NXOpen
Module Module9
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim sketchLayer As Integer = 33
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.NewLayer = sketchLayer
'displayModification1.Apply(workPart.Annotations.Centerlines.ToArray)
'displayModification1.Apply(workPart.Annotations.Datums.ToArray)
displayModification1.Apply(workPart.Annotations.PmiHorizontalDimension.ToArray)
displayModification1.Dispose()
End Sub
End Module