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: 

color

1 REPLY 1
Reply
Message 1 of 2
dhanshri_gavas
120 Views, 1 Reply

color

Hi Team,
In Inventor, how do I get the color of each occurrence using the API?  in the part and assembly document?  
Thanks in advance!

1 REPLY 1
Message 2 of 2

Hi @dhanshri_gavas . To get the color of the part, you need to use the ActiveAppearance method. This method will give you the active Asset. An example of getting an Asset in assemblies and details is below:

 

Public Sub Main()
	Dim oDoc As Document = ThisDoc.Document
	If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		Dim oADoc As AssemblyDocument = oDoc
		Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
		For Each oRefDoc As PartDocument In oADoc.AllReferencedDocuments.OfType(Of PartDocument)
			If oOccs.AllLeafOccurrences(oRefDoc.ComponentDefinition).Count = 0 Then Continue For
			Call GetColorDoc(oRefDoc)
		Next
	Else If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Dim oPDoc As PartDocument = oDoc
		Call GetColorDoc(oPDoc)
	End If
End Sub

Private Function GetColorDoc(ByVal oPDoc As PartDocument)
	Dim oAsset As Asset = oPDoc.ActiveAppearance
	Logger.Info("Part - " & oPDoc.DisplayName)
	Logger.Info("Color - " & oAsset.DisplayName & vbLf)
End Function

 

This code gets the Asset in line 17 and then shows the color information in the iLogic Log.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

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

Post to forums  

Autodesk Design & Make Report