×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to get the unused expressions?

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

RE: How to get the unused expressions?

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!

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?

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

RE: How to get the unused expressions?

(OP)
I has found that some expressions link with sketch and drawings,not only features. how to retrieves these 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?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources