Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the unused expressions?

Status
Not open for further replies.

anthonyo

Mechanical
Oct 10, 2007
4
0
0
CN
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
 
Replies continue below

Recommended for you

All you have to do is go to tool==>expression=> and under listed expressions change it to unused expressions.. This will show you all unused expressions.

Hope thats what you wanted to know!
 


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

 
I get two compile errors when cutting/pasting that code

Line 11: 'Module' statement must end with a matching 'End Module'
Line 33: 'GetOwningFeature' is not a member of 'NXOpen.Expression'



Justin Ackley
Designer
 

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.



 
Hi HariharanB: I use the UF_MODL_ask_features_of_exp() to retrieves the unused exps and the UF_SKET_ask_exps_of_sketch() to retrieve the used exps in display part, also need to identifying some other exps.
 
Status
Not open for further replies.
Back
Top