How to get the unused expressions?
How to get the unused expressions?
(OP)
Hi
I want to get the unused expressions in the part by open api, but has no found the function, who can help me?
thanks
I want to get the unused expressions in the part by open api, but has no found the function, who can help me?
thanks





RE: How to get the unused expressions?
Hope thats what you wanted to know!
RE: How to get the unused expressions?
Hi,
To check in a display part the following code would help.But need to add few more checks for identifying interpart exps, geometric exps ....
Try executing this as a journal
Imports System
Imports System.Windows.Forms
Imports System.Collections
Imports NXOpen
Imports NXOpen.Assemblies
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.UF
Public Module query
Public UFS As UFSession = UFS.getufsession
Public NTS As Session = NTS.getsession
Sub Main()
Try
' / Get the displayed part /
Dim dispPart As Part = NTS.Parts.Display
' / Retrieve part expressions /
Dim partExps As ExpressionCollection = dispPart.Expressions
Dim unusedExps As New ArrayList
Dim t_expn As Expression
' / Iterate through the expressions in the part /
For Each t_expn In partExps
If (t_expn.GetOwningFeature Is Nothing) Then
' / Add the unused expression into arraylist /
unusedExps.Add(t_expn)
' / Direct the information to window /
writeToWindow(t_expn.Name + " : " + t_expn.Value.ToString)
End If
Next
Catch ex As Exception
MessageBox.Show("Retrieving expression not sucessful", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Sub writeToWindow(ByVal strContent As String)
Try
' / Check for the status of the listing window /
If Not (NTS.ListingWindow.IsOpen) Then
NTS.ListingWindow.Open()
End If
NTS.ListingWindow.WriteLine(strContent)
Catch ex As Exception
MessageBox.Show("Unable to write to listing output device", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
RE: How to get the unused expressions?
Line 11: 'Module' statement must end with a matching 'End Module'
Line 33: 'GetOwningFeature' is not a member of 'NXOpen.Expression'
Justin Ackley
Designer
RE: How to get the unused expressions?
RE: How to get the unused expressions?
Hi anthonyo : Kindly change the "t_expn.GetOwningFeature" to "t_expn.GetUsingFeatures", this would even include sketch and all registered features
Hi Jackley : I am guessing that you are using NX4.0.0, if you can try my code with NX4.0.3.3. the compilation and non-reference errors may dissolve.
RE: How to get the unused expressions?