Change Face Color of Part With iLogic

Change Face Color of Part With iLogic

insomnix
Advocate Advocate
1,844 Views
2 Replies
Message 1 of 3

Change Face Color of Part With iLogic

insomnix
Advocate
Advocate

I am working in a part file where I would like to change two faces to a specific color based on criteria. Below is a simplified version of the code and where it is failing. Both faces already have a color assigned and the code does find those two faces. However, when trying to call SetRenderStyle, the code errors and no faces are actually updated. 

I am in Inventor 2018.

 

 

    Dim oPartDoc As PartDocument 
    oPartDoc = ThisApplication.ActiveDocument 

    ' Get all of the faces that have the "FaceColor" attribute. 
    Dim oFaces As ObjectCollection 
    oFaces = oPartDoc.AttributeManager.FindObjects( "com.autodesk.inventor.FaceAttributes", "FaceColor")

    ' Iterate through all faces that have colors and change. 
    Dim oFace As Face
    Dim oStyle As RenderStyle
    For Each oFace In oFaces 
		oStyle = oPartDoc.RenderStyles.Item("Beige")
		Call oFace.SetRenderStyle(kOverrideAppearance, oStyle) 
    Next 

 

0 Likes
Accepted solutions (1)
1,845 Views
2 Replies
Replies (2)
Message 2 of 3

R.Mabery
Advocate
Advocate
Accepted solution

Hi insomnix,

 

Use Assets & the Appearance property instead.  Something like below:

Dim oAssets as Assets
oAssets = oPartDoc.Assets
	
Dim oAsset as Asset
oAsset = oAssets.Item("Bamboo")
    
For Each oFace In oFaces 
     oFace.Appearance = oAsset
Next

  


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
Message 3 of 3

insomnix
Advocate
Advocate

Works great!

 

Thanks