Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module2
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim theUi As UI = UI.GetUI
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()
Const undoMarkName As String = "NXJ body display properties"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
Dim theBodies As New List(Of Body)
If SelectBodies("select bodies", theBodies) = Selection.Response.Cancel Then
'user pressed cancel
lw.WriteLine("cancel")
Return
End If
Dim displayModification1 As DisplayModification = theSession.DisplayManager.NewDisplayModification()
'specify new layer (1 - 256)
displayModification1.NewLayer = 1
'specify new color (CDF palette entry 1 - 216)
displayModification1.NewColor = 6
'specify line font
' DisplayableObject.ObjectFont.Centerline
' DisplayableObject.ObjectFont.Dashed
' DisplayableObject.ObjectFont.Dotted
' DisplayableObject.ObjectFont.DottedDashed
' DisplayableObject.ObjectFont.LongDashed
' DisplayableObject.ObjectFont.Phantom
' DisplayableObject.ObjectFont.Solid
displayModification1.NewFont = DisplayableObject.ObjectFont.Dashed
'specify translucency %
displayModification1.NewTranslucency = 50
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False
displayModification1.Apply(theBodies.ToArray)
displayModification1.Dispose()
lw.Close()
End Sub
Function SelectBodies(ByVal prompt As String, ByRef selBodies As List(Of Body)) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a body"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
Dim selObjs() As TaggedObject
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt,
title, scope, selAction,
includeFeatures, keepHighlighted, selectionMask_array,
selObjs)
If resp = Selection.Response.Back OrElse resp = Selection.Response.Cancel Then
Return Selection.Response.Cancel
Else
For Each tempObj As TaggedObject In selObjs
selBodies.Add(tempObj)
Next
Return Selection.Response.Ok
End If
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
End Function
End Module