Changing Part material and appearance inside Assembly with iLogic

Changing Part material and appearance inside Assembly with iLogic

Daan_M
Collaborator Collaborator
923 Views
1 Reply
Message 1 of 2

Changing Part material and appearance inside Assembly with iLogic

Daan_M
Collaborator
Collaborator

Hi,

 

I am trying to change the material and appearance (color) of all parts inside my assembly, so they all have the same color and it looks tidy.

 

Right now i am trying to check all referenced part documents and change their material/appearance. It seems like the material part is working, but im not sure how to adjust the appearance/color. I'm accessing the appearance the wrong way, i tried looking in the API object model but haven't managed to find it.

 

 

 

 

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim pDoc As Document

Dim oMaterialName As String = "Generic"
Dim oAppearanceName As String = "Default"

Dim oMaterial As Material = oDoc.Materials.item(oMaterialName)
Dim oRenderStyle As RenderStyle = oDoc.RenderStyles.Item(oAppearanceName)

For Each pDoc In oDoc.AllReferencedDocuments

	If pDoc.DocumentType = kPartDocumentObject

		Dim oPartDoc As PartDocument = pDoc

		oPartDoc.ComponentDefinition.Material = oMaterial
		oPartDoc.ComponentDefinition.ActiveRenderStyles = oRenderStyle

	End If
Next

 

 

 

 

Maybe i can do something with the Assets? API object models sais this has to do with the appearance and color, but i'm also not sure how to use this any further;

 

 

Dim oAsset As Asset = oDoc.Assets 'not sure how to complete the code here

 

 

  

Any tips how i can get all parts in my document the same color and material? Thanks

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

JelteDeJong
Mentor
Mentor
Accepted solution

This will not colour the documents themselves but the components in the assembly.

Dim doc As AssemblyDocument = ThisDoc.Document

Dim asset As Asset = doc.Assets.Item("Default")
For Each occ As ComponentOccurrence In doc.ComponentDefinition.Occurrences

    occ.Appearance = asset

Next

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes