HagenT
Mechanical
- Dec 1, 2015
- 14
Hi all together,
i try to find a way to syncron the part attributes to the assembly.
In this case i found AssembliesGeneralPropertiesBuilder and tried out the following code but it doesn´t work.
Can somebody help please.
Thanks
i try to find a way to syncron the part attributes to the assembly.
In this case i found AssembliesGeneralPropertiesBuilder and tried out the following code but it doesn´t work.
Code:
Sub Main(ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
Dim cw As ComponentAssembly = workPart.ComponentAssembly
If Not IsNothing(cw.RootComponent) Then
For Each child As Component In cw.RootComponent.GetChildren()
Dim objects1(0) As NXObject
objects1(0) = child
Dim assembliesGeneralPropertiesBuilder1 As Assemblies.AssembliesGeneralPropertiesBuilder
assembliesGeneralPropertiesBuilder1 = workPart.PropertiesManager.CreateAssembliesGeneralPropertiesBuilder(objects1)
assembliesGeneralPropertiesBuilder1.SynchronizeAttributes()
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Komponente Eigenschaften")
theSession.DeleteUndoMark(markId2, Nothing)
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Komponente Eigenschaften")
Dim nXObject1 As NXObject
nXObject1 = assembliesGeneralPropertiesBuilder1.Commit()
'workPart.PartPreviewMode = BasePart.PartPreview.None
Dim id1 As Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.Visible)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(id1, "Komponente Eigenschaften")
assembliesGeneralPropertiesBuilder1.Destroy()
Next
End If
End Sub
Can somebody help please.
Thanks