iLogic - Pull Material from specific part to assembly

iLogic - Pull Material from specific part to assembly

frederik_vollbrecht
Advocate Advocate
543 Views
1 Reply
Message 1 of 2

iLogic - Pull Material from specific part to assembly

frederik_vollbrecht
Advocate
Advocate

Hi,

I just got some time to write a dirty iLogic to pull the Material from a part to the assembly.

I wrote this, because most of the time when designing sheet metal assemblys with pressed bolts etc. the assembly and the main sheet metal part get the same name.

 

 

0 Likes
Accepted solutions (1)
544 Views
1 Reply
Reply (1)
Message 2 of 2

frederik_vollbrecht
Advocate
Advocate
Accepted solution
' 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
0 Likes