Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Register Log in

Deleting Expression

pramit.associat

New member
METHOD-1
If you willing to accept the fact that if you "...clear/delete all expressions and interpart data..." from you Part model, that this will remove all features and paratmeters from the model as well (i.e. make it a 'dumb' model), then there are a couple of approaches that you could take.

The quickest way to do this would be to go to...

File -> Export -> Part...

...and with the 'Feature Parameters' option set to 'Remove Parameters', select all of the bodies and curves which you wish to retain in their 'dumb' state, enter the name of new file and hit OK. Now you'll have a new part file with all of the features and parameters removed.

An alternative, in case you don't want to create a new Part file, is to go to...

Edit -> Feature -> Remover Parameters...

...select all of the features in the Part model and hit OK. You may still need to go to open the Expression dialog and delete any leftover expressions.
METHOD-2
"a number of parts and a assembly which uses inter-part link and values from a external spread sheet"

Maybe the cleaning can be simplified by exporting the expressions to a separate file, clean the external file , import.
( Tools- expression - export expressions to file and Import...)
Sadly the expression in the text file only shows as expression, not the current value.
i.e
ug_excel_read( "C:\temp\Book1.xlsx", "B2" )
and not that the current value of cell "B2" happens to be "100"

The following example nxopen/journal works on the displayed part and will replace the right hand side formula of any numerical expression with the evaluated value.

CODE --> vb.net

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module simplify_expressions

Dim s As Session = Session.GetSession()

Sub Main()

Dim dp As Part = s.Parts.Display
Dim exps() As Expression = dp.Expressions.ToArray()

For Each thisExp As Expression In exps

If thisExp.Type.ToString().Contains("Number") Then

dp.Expressions.Edit(thisExp, thisExp.Value().ToString())

End If

Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

Return Session.LibraryUnloadOption.Immediately

End Function

End Module



SAVE THE BELOW CODES as filename.vb(any name under filename)
' This will remove the defining formula from the righthand side of each
' numeric expression in the displayed part, and replace it with the value.
'
' This would be useful, for example, if you wanted to strip out any
' interpart expression information but retain the current values.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module simplify_expressions

Dim s As Session = Session.GetSession()

Sub Main()

Dim dp As Part = s.Parts.Display
Dim exps() As Expression = dp.Expressions.ToArray()

For Each thisExp As Expression In exps

If thisExp.Type.ToString().Contains("Number") Then

dp.Expressions.Edit(thisExp, thisExp.Value().ToString())

End If

Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

Return Session.LibraryUnloadOption.Immediately

End Function

End Module




import it and it will reset...........
 

Sponsor

Top