cancel
Showing results for 
Search instead for 
Did you mean: 

edit settings of all centerlines

Legend
Legend

Hi,

I've found this code very useful:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Annotations

Module edit_settings_of_all_centerlines
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow

Dim count As Integer = 0
Dim gap as Double = 1.5
Dim size as Double = 3.0
Dim extension as Double = 3.0

lw.Open()
For each cline As Centerline in workPart.Annotations.Centerlines
    count = count+1
    'lw.WriteLine(count.ToString() & ". " & cline.ToString() & " Type: " & cline.GetType().ToString())

    If TypeOf cline Is NXOpen.Annotations.Centerline3d Then
        Dim centerline3dBuilder1 As Annotations.Centerline3dBuilder
        centerline3dBuilder1 = workPart.Annotations.Centerlines.CreateCenterline3dBuilder(cline)
        centerline3dBuilder1.Settings.Gap = gap
        centerline3dBuilder1.Settings.Size = size
        centerline3dBuilder1.Settings.Extension = extension
        Dim nXObject1 As NXObject
        nXObject1 = centerline3dBuilder1.Commit()
        centerline3dBuilder1.Destroy()

    Else If TypeOf cline Is NXOpen.Annotations.Centerline2d Then
        Dim centerline2dBuilder1 As Annotations.Centerline2dBuilder
        centerline2dBuilder1 = workPart.Annotations.Centerlines.CreateCenterline2dBuilder(cline)
        centerline2dBuilder1.Settings.Gap = gap
        centerline2dBuilder1.Settings.Size = size
        centerline2dBuilder1.Settings.Extension = extension
        Dim nXObject2 As NXObject
        nXObject2 = centerline2dBuilder1.Commit()
        centerline2dBuilder1.Destroy()

    Else If TypeOf cline Is NXOpen.Annotations.SymmetricalCenterline Then
        Dim symcenterlineBuilder1 As Annotations.SymmetricalCenterlineBuilder
        symcenterlineBuilder1 = workPart.Annotations.Centerlines.CreateSymmetricalCenterlineBuilder(cline)
        symcenterlineBuilder1.Settings.Gap = gap
        symcenterlineBuilder1.Settings.Size = size
        symcenterlineBuilder1.Settings.Extension = extension
        Dim nXObject2 As NXObject
        nXObject2 = symcenterlineBuilder1.Commit()
        symcenterlineBuilder1.Destroy()

    Else If TypeOf cline Is NXOpen.Annotations.CenterMark Then
        Dim centermarkBuilder1 As Annotations.CenterMarkBuilder
        centermarkBuilder1 = workPart.Annotations.Centerlines.CreateCenterMarkBuilder(cline)
        centermarkBuilder1.Settings.Gap = gap
        centermarkBuilder1.Settings.Size = size
        centermarkBuilder1.Settings.Extension = extension
        Dim nXObject2 As NXObject
        nXObject2 = centermarkBuilder1.Commit()
        centermarkBuilder1.Destroy()

    Else If TypeOf cline Is NXOpen.Annotations.BoltCircleCenterline Then
        Dim bcirccenterlineBuilder1 As Annotations.BoltCircleCenterlineBuilder
        bcirccenterlineBuilder1 = workPart.Annotations.Centerlines.CreateBoltCircleCenterlineBuilder(cline)
        bcirccenterlineBuilder1.Settings.Gap = gap
        bcirccenterlineBuilder1.Settings.Size = size
        bcirccenterlineBuilder1.Settings.Extension = extension
        Dim nXObject2 As NXObject
        nXObject2 = bcirccenterlineBuilder1.Commit()
        bcirccenterlineBuilder1.Destroy()

    Else 
        lw.WriteLine(" -> Unknown Centerline Type")
    End If
Next
Return


End Sub
End Module

 Can someone implement this code adding block style like the image attached Center Mark.png where I edit predefined value, in the manner that I avoid edit each time the code if I want to change the centerline setting ?

Thank you...

Using NX 11 / RuleDesigner PDM