Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get Custom Colors from Appearance via API

4 REPLIES 4
Reply
Message 1 of 5
mahesh.revanwar
854 Views, 4 Replies

How to get Custom Colors from Appearance via API

Hello All,

 

We need to get all color information for all parts from Fusion model via API. I need this information for my plugin for Fusion360.

We are facing issue when colors are overridden and applied as custom appearances. We get incorrect color values from API when custom colors are applied.


Please refer following code snippet,

 

adsk::core::Ptr<adsk::fusion::BRepFaces> bfaces = body->faces();
adsk::core::Ptr<adsk::fusion::BRepFace> face = bfaces->item(0);
adsk::core::Ptr<adsk::core::ColorProperty> colorprop = nullptr;
colorprop = face->appearance()->appearanceProperties()->itemById("wood_early_color");

 

 

We are using following IDs to get color properties.
"opaque_albedo"
"metal_f0"
"layered_diffuse"
"transparent_color"
"wood_early_color"

 

Should we use any other IDs to get correct colors from Appearance? Or is there some other API to get correct Custom Colors values from Appearance via API?


Thank you for all your help.

 

Regards,
Mahesh

4 REPLIES 4
Message 2 of 5
goyals
in reply to: mahesh.revanwar

Hi @mahesh.revanwar,

 

One way is you can iterate through appearance properties and look for objectType on property equals to adsk::core::ColorProperty. Then you can check for hasConnectedTexture on property to see if that property contains a texture or just a color. Hope it helps.

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
Message 3 of 5
ProtoTechSolutions
in reply to: goyals

Hi Shyam,

I'm getting similar issue for getting colors from Fusion. I've also tried provided solution by you but some colors are still missing. Please guide me to get the exact colors from Fusion using Fusion APIs. 

Message 4 of 5
goyals
in reply to: ProtoTechSolutions

May I know is it not working for any particular appearance you applied on body and Fusion API is not returning any color property for that appearance or color property is returned but values are wrong. It will help me to try for that particular appearance on my side. Thanks



Shyam Goyal
Sr. Software Dev. Manager
Message 5 of 5
ProtoTechSolutions
in reply to: goyals

Hi Shyam,

We are fetching color property from appearance IDs present on the particular part.
e.g opaque_f0, concrete_color, generic_diffuse, opaque_albedo etc.
Please refer attached fusion (.f3d) file having parts which are not returning correct color values.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report