Forums:
Hello
Below is a journal that creates an expression and if run the second time it should edit expression value that was created in the first run. Do i need another block of code to handle errors?
Imports System Imports NXOpen Module create expression Public theSession As Session = Session.GetSession()Public workPart As Part = theSession.Parts.Work Sub Main() Dim leftPart AsString="12"Dim expression1 As NXOpen.Expression=NothingDim thr_exp As NXOpen.Expression=NothingDim expression_a AsString="thr_txt" 'create expression TryDim theExp As Expression = workPart.Expressions.FindObject(expression_a) workPart.Expressions.Edit(theExp, "M""+stringValue( "& leftPart &" )") Catch ex As NXException ex.AssertErrorCode(3520016) expression1 = workPart.Expressions.CreateExpression("String", expression_a &"=""M""+stringValue( "& leftPart &" )")EndTry EndSub PrivateSub Echo(ByVal output AsString) theSession.ListingWindow.Open() theSession.ListingWindow.WriteLine(output) theSession.LogFile.WriteLine(output)EndSub PublicFunction GetUnloadOption(ByVal arg AsString)AsIntegerReturn System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately)EndFunction EndModule