' Pull Material from sheet metal part to sheet metal assembly
' Copyright Frederik Vollbrecht 2020
' V 1.0
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Get the definition of the assembly.
Dim oAsmDef As AssemblyComponentDefinition
oAsmDef = oAsmDoc.ComponentDefinition
' Some kind of error handling
Try
' Get the document to find occurrences for. It will be asumed that both, part
' and assembly, have the same filename
Dim oDoc As Document
oDoc = ThisApplication.Documents.ItemByName( ThisDoc.PathAndFileName(False) & ".ipt")
' Get the occurrences that represent this document.
Dim oOccs As ComponentOccurrencesEnumerator
oOccs = oAsmDef.Occurrences.AllReferencedOccurrences(oDoc)
' Set definition of the Material var
oMat = oDoc.ComponentDefinition.Material.Name
' Create iProperty in the assembly containing the part material
iProperties.Value("Custom", "Material") = oMat
Catch
MessageBox.Show("Baugruppe enthält keine Blechkonstruktion", "Fehler")
End Try