Need Journal Help for Value Assertion and Save-As
Need Journal Help for Value Assertion and Save-As
(OP)
Hi,
I am looking to automate an assembly, but I'm trying to do it without interpart expressions in the lower level components looking up to the master assembly. I am doing this because IPEs don't always update, I don't want them looking at the same assembly post save-as, and I'd like a cleaner way to do a 1-time assertion of value and then not have an IPE connection. All of the journaling I have recorded myself has gone through "make displayed part" operations and then "workPart.Expressions.EditWithUnits(expression3, unit2, """COMPONENT/01""::EXPRESSION_NAME")" type operations to identify the expression and the value to assign. Does anybody know of a means of identifying a part number, an expression, and a value to assert in one operation without changing part files? I am also looking to do something similar with a save-as. I would like to identify the current part number and do a save-as to a number part number I identify, similar to a clone, not with dissimilar string values.
Does anybody have some familiarity with this?
I could do all of this through IPEs and manual save-as, but I'd like to try something a little new and cleaner.
Thank you!
I am looking to automate an assembly, but I'm trying to do it without interpart expressions in the lower level components looking up to the master assembly. I am doing this because IPEs don't always update, I don't want them looking at the same assembly post save-as, and I'd like a cleaner way to do a 1-time assertion of value and then not have an IPE connection. All of the journaling I have recorded myself has gone through "make displayed part" operations and then "workPart.Expressions.EditWithUnits(expression3, unit2, """COMPONENT/01""::EXPRESSION_NAME")" type operations to identify the expression and the value to assign. Does anybody know of a means of identifying a part number, an expression, and a value to assert in one operation without changing part files? I am also looking to do something similar with a save-as. I would like to identify the current part number and do a save-as to a number part number I identify, similar to a clone, not with dissimilar string values.
Does anybody have some familiarity with this?
I could do all of this through IPEs and manual save-as, but I'd like to try something a little new and cleaner.
Thank you!





RE: Need Journal Help for Value Assertion and Save-As
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim mySelComp As TaggedObject If SelectComponent("select a component", mySelComp) = Selection.Response.Cancel Then Exit Sub End If Dim myComp As Assemblies.Component = mySelComp Dim myCompPart As Part myCompPart = myComp.Prototype.OwningPart lw.WriteLine("Expressions in Component: " & myComp.Name) For Each tempExp As Expression In myCompPart.Expressions 'If tempExp.Name = "dia" Then ' Dim markId1 As Session.UndoMarkId ' markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") ' myCompPart.Expressions.Edit(tempExp, "3") ' Dim nErrs1 As Integer ' nErrs1 = theSession.UpdateManager.DoUpdate(markId1) 'End If lw.WriteLine(tempExp.Name & " = " & tempExp.RightHandSide) Next lw.WriteLine("") lw.Close() End Sub Function SelectComponent(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select a component" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim cursor As Point3d Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_component_type .Subtype = UFConstants.UF_all_subtype End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj, cursor) If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Modulewww.nxjournaling.com
RE: Need Journal Help for Value Assertion and Save-As
Thank you VERY much, that was a huge help. I am successfully pushing string values using this method, so that you for getting me this far. Do you happen to know how to read the value of a string into the place where you are setting tempExp equal to 3? My goal is to set a string value at the top level, read this value into where you call out the integer 3, then put an if statement to assign this string value to an expression in a lower level component if found. I'm having an issue with the syntax that doesn't just pass the variable name into the lower level. Do you know if this is possible?
Thank you again for your help this far, this message board is fortunate to have you around.
RE: Need Journal Help for Value Assertion and Save-As
CODE
If your expressions have units associated with them, use the .EditWithUnits() method instead.
www.nxjournaling.com