'NXJournaling.com
'October 5, 2016
'Determine if there is an expression that controls a dimension (the controlling dimension determines if the dimension is suppressed or not).
'[URL unfurl="true"]http://nxjournaling.com/comment/3944#comment-3944[/URL]
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")
lw.Open()
'find dimensions that are controlled (suppress/unsuppress) by expression
For Each temp As Annotations.Dimension In theSession.Parts.Work.Dimensions
'Dim expTag As Tag = Tag.Null
'theUfSession.Drf.AskAssocExp(temp.Tag, expTag)
'If Not expTag = Tag.Null Then
' lw.WriteLine("dim: " & temp.Tag.ToString & " exp tag: " & expTag.ToString)
'Else
' lw.WriteLine("dim: " & temp.Tag.ToString & " no associated expression")
'End If
Dim controllingExpTag As Tag = Tag.Null
theUfSession.Drf.AskControllingExp(temp.Tag, controllingExpTag)
If Not controllingExpTag = Tag.Null Then
Dim controllingExp As Expression = Utilities.NXObjectManager.Get(controllingExpTag)
lw.WriteLine("dimension tag: " & temp.Tag.ToString & " controlling expression tag: " & controllingExpTag.ToString)
lw.WriteLine(" " & controllingExp.Name & " = " & controllingExp.RightHandSide)
'expression value = 0: object suppressed
'expression value = 1: object unsuppressed
Else
lw.WriteLine("dim: " & temp.Tag.ToString & " no controlling expression")
End If
Next
'find drafting objects that are controlled by expression (suppress/unsuppress)
For Each tempExp As Expression In theSession.Parts.Work.Expressions
Dim numObjs As Integer
Dim objTags() As Tag = Nothing
theUfSession.Drf.AskObjectsControlledByExp(tempExp.Tag, numObjs, objTags)
If numObjs > 0 Then
lw.WriteLine("expression: " & tempExp.Name)
For Each tempTag As Tag In objTags
lw.WriteLine(" controlled object tag: " & tempTag.ToString)
Next
lw.WriteLine("")
End If
Next
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'----Other unload options-------
'Unloads the image when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module