Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Sub Main()
Dim selobj As NXObject
Dim type As Integer
Dim subtype As Integer
Dim lw As ListingWindow = theSession.ListingWindow
Dim theUI As UI = UI.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
'process the preselected dimensions
If numsel > 0 Then
For inx As Integer = 0 To numsel - 1
selobj = theUI.SelectionManager.GetSelectedObject(inx)
theUfSession.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
If type = UFConstants.UF_dimension_type Then
Dim theDim As Annotations.Dimension
theDim = DirectCast(selobj, Annotations.Dimension)
ToggleDimArrows(theDim)
End If
Next
Else
'prompt to select dimensions
Dim myDims As New List(Of Annotations.Dimension)
If SelectDimensions("Select Dimensions to toggle arrows", myDims) = Selection.Response.Cancel Then
Return
End If
For Each tempDim As Annotations.Dimension In myDims
ToggleDimArrows(tempDim)
Next
End If
End Sub
Sub ToggleDimArrows(ByVal theDim As Annotations.Dimension)
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "toggle arrows")
Dim dimensionPreferences1 As Annotations.DimensionPreferences
dimensionPreferences1 = theDim.GetDimensionPreferences()
If dimensionPreferences1.TextPlacement = Annotations.TextPlacement.ManualArrowsIn Then
dimensionPreferences1.TextPlacement = Annotations.TextPlacement.ManualArrowsOut
ElseIf dimensionPreferences1.TextPlacement = Annotations.TextPlacement.ManualArrowsOut Then
dimensionPreferences1.TextPlacement = Annotations.TextPlacement.ManualArrowsIn
End If
theDim.SetDimensionPreferences(dimensionPreferences1)
dimensionPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
End Sub
Function SelectDimensions(ByVal prompt As String, ByRef someDims As List(Of Annotations.Dimension)) As Selection.Response
Dim selObj() As NXObject
Dim theUI As UI = UI.GetUI
Dim title As String = "Select dimensions"
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.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_dimension_type
.Subtype = UFConstants.UF_all_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj)
If resp = Selection.Response.Ok Then
For Each temp As Annotations.Dimension In selObj
someDims.Add(temp)
Next
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
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
'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module