Forums:
This is the code I've developed so far using record macro but it's not working. The code executes without errors but doesn't actually save-as a new part. Any advice?
'Journal to recursively walk through the assembly structure ' will run on assemblies or piece parts ' will step through all components of the displayed part 'NX 7.5, native 'NXJournaling.com February 24, 2012 Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.Assemblies Module NXJournal Public theSession As Session = Session.GetSession() Public ufs As UFSession = UFSession.GetUFSession() Public lw As ListingWindow = theSession.ListingWindow Public workPart As NXOpen.Part = theSession.Parts.Work Public dispPart as NXOpen.Part = theSession.Parts.Display Public fileNameNoExt As String Public basePart1 As NXOpen.BasePart = Nothing Public partLoadStatus1 As NXOpen.PartLoadStatus = Nothing Public PartNames(0) As String Public FLART(3) as string Public ArrayIndex as integer = 0 Public i as integer = 0 Public j as integer Public match as integer = 0 Public theUISession As UI = UI.GetUI Public c As ComponentAssembly = dispPart.ComponentAssembly Public partOperationCopyBuilder1 As NXOpen.PDM.PartOperationCopyBuilder = Nothing Sub Main() FLART(0) = "MY_PART" FLART(1) = FLART(2) = FLART(3) = lw.Open Dim selectedparts1(0) As NXOpen.BasePart Dim failedparts1() As NXOpen.BasePart Dim logicalobjects1() As NXOpen.PDM.LogicalObject Dim sourceobjects1() As NXOpen.NXObject Dim attributePropertiesBuilder1 As NXOpen.AttributePropertiesBuilder = Nothing Dim objects2(0) As NXOpen.NXObject Dim nullNXOpen_BasePart As NXOpen.BasePart = Nothing 'TRIES TO OPEN THE PART SPECIFIED IN THE ARRAY basePart1 = theSession.Parts.OpenActiveDisplay("@DB/" & FLART(i) & "/" & 1, NXOpen.DisplayPartOption.AllowAdditional, partLoadStatus1) workPart = theSession.parts.work dispPart = thesession.parts.display c = dispPart.ComponentAssembly selectedparts1(0) = workPart partOperationCopyBuilder1 = theSession.PdmSession.CreateCopyOperationBuilder(NXOpen.PDM.PartOperationBuilder.OperationType.SaveAs) partOperationCopyBuilder1.SetOperationSubType(NXOpen.PDM.PartOperationCopyBuilder.OperationSubType.Default) partOperationCopyBuilder1.DefaultDestinationFolder = ":Newstuff" partOperationCopyBuilder1.DependentFilesToCopyOption = NXOpen.PDM.PartOperationCopyBuilder.CopyDependentFiles.All partOperationCopyBuilder1.ReplaceAllComponentsInSession = True partOperationCopyBuilder1.SetDialogOperation(NXOpen.PDM.PartOperationBuilder.OperationType.SaveAs) selectedparts1(0) = workPart partOperationCopyBuilder1.SetSelectedPartsToCopy(selectedparts1, failedparts1) partOperationCopyBuilder1.CreateLogicalObjects(logicalobjects1) sourceobjects1 = logicalobjects1(0).GetUserAttributeSourceObjects() attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(nullNXOpen_BasePart, objects2, NXOpen.AttributePropertiesBuilder.OperationType.None) objects2(0) = sourceobjects1(0) attributePropertiesBuilder1.SetAttributeObjects(objects2) attributePropertiesBuilder1.Title = "DB_PART_NO" attributePropertiesBuilder1.Category = "N4_NonDesignPart" attributePropertiesBuilder1.StringValue = "TEMP_DELETE_ITEM" partOperationCopyBuilder1.ValidateLogicalObjectsToCommit() partOperationCopyBuilder1.Destroy() attributePropertiesBuilder1.Destroy() theSession.CleanUpFacetedFacesAndEdges() theSession.Parts.Display.Close(BasePart.CloseWholeTree.True, BasePart.CloseModified.UseResponses, Nothing) lw.Close End Sub<code>