Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic - Pull Material from specific part to assembly

1 REPLY 1
SOLVED
Reply
Message 1 of 2
frederik_vollbrecht
458 Views, 1 Reply

iLogic - Pull Material from specific part to assembly

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.

 

 

1 REPLY 1
Message 2 of 2

' 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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report