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: 

How to override a solid body color from an assembly

4 REPLIES 4
Reply
Message 1 of 5
sergio_duran
520 Views, 4 Replies

How to override a solid body color from an assembly

Hi everyone,

 

I would like to know how to override a solid body color from an assembly using either VBA (API) or VB.NET (iLogic).

 

There is another thread in which the color of bodies from a multi-body part are changed, then I adjusted it to do the same from the assembly but it changes the original body color rather than override it in the assembly level. In my code, I'm checking occurrence by occurrence, filtering only parts with more than one body, and finally, changing the color of solid bodies. It works well, but it changes the original color of every body.

 

Here is the thread 

http://forums.autodesk.com/t5/inventor-customization/how-do-i-change-the-color-of-a-solid-in-a-multi...

 

iLogic has this snippet (please see below) to override a component color in the assembly level but the original color will remain the same.

 

SyntaxEditor Code Snippet

Component.Color("PartA:1")

 

I'd like to do something similar for solid bodies

 

Thanks in advance!

4 REPLIES 4
Message 2 of 5

serduro,

 

Good morning!  I haven't tried to run this for a little while, but here is a code snippet that I have used as a basis for a similar task in the past.  Let me know if you have any questions, hope all is well and have a most blessed day!

 

doc = ThisDoc.Document
oDef = doc.ComponentDefinition

'assume there are two appearances in the documents
oGold_Color = doc.Assets("Gold - Metal")
oStones_Color = doc.Assets("Small Uneven Rectanguler Stones - Brown")

'if change all bodies with same color

' in some cases, we need to declare the variable explictly
Dim oSB As SurfaceBody
For Each oSB In oDef.SurfaceBodies
    oSB.Appearance = oGold_Color
Next

' if change specific body to specific color
Dim oSB1 As SurfaceBody
oSB1 = oDef.SurfaceBodies(1)
oSB1.Appearance = oGold_Color

Dim oSB2 As SurfaceBody
oSB2 = oDef.SurfaceBodies(2)
oSB2.Appearance = oStones_Color

 

Peace,
Pete

Just a guy on a couch...

Please give a kudos if helpful and mark as a solution if somehow I got it right.
Message 3 of 5
sergio_duran
in reply to: sergio_duran

Sorry, this is the wrong discussion group because the post is about Inventor customization

Message 4 of 5

Thanks! I'll check your code
Message 5 of 5

thanks Pete, but it didn't work!

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report