based on cowski suggestion yesterday, here is the simple code for updating all model, for simplicity, i didnt link to Excel but just ask the cdeo to find a specific parameter and replace the value, after that, update the model
the purpose i want to do this code is that later on i want to have two models, model 1 and 2, model 2 has some parameters controlled by model 1, yes, use interpart relationship, such a poweful finding!!!!!!
Code:
'loop through all models and update
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Annotations
Imports System.Text.RegularExpressions
Imports System.Collections.Generic
Imports System.IO
Imports System.Windows.Forms
Imports NXOpen.Assemblies
Module updateAllModelfgh
Dim theSession As Session = Session.GetSession()
Dim LW As ListingWindow = theSession.ListingWindow
Sub Main()
Dim workpart As Part = theSession.Parts.Work
LW.Open()
For Each part As Part In theSession.Parts
Dim partLoadStatus As PartLoadStatus
Dim status1 As PartCollection.SdpsStatus
status1 = theSession.Parts.SetDisplay(part, False, False, partLoadStatus)
Try
For Each NXExp As Expression In part.Expressions
'replace expression
If NXExp.Name = "diameter" Then
NXExp.RightHandSide = "8"
End If
Next
Dim upDateMark1 As Session.UndoMarkId
theSession.UpdateManager.DoUpdate(upDateMark1)
Catch ex As NXException
If ex.ErrorCode = 3520016 Then
LW.WriteLine("No expressions in NX were found that can match with the external expressions")
Else
LW.WriteLine(ex.ErrorCode & ": " & ex.Message)
End If
End Try
Next
End Sub
End Module
the purpose i want to do this code is that later on i want to have two models, model 1 and 2, model 2 has some parameters controlled by model 1, yes, use interpart relationship, such a poweful finding!!!!!!