How to get Custom Colors from Appearance via API

How to get Custom Colors from Appearance via API

Anonymous
Not applicable
1,394 Views
4 Replies
Message 1 of 5

How to get Custom Colors from Appearance via API

Anonymous
Not applicable

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

0 Likes
1,395 Views
4 Replies
Replies (4)
Message 2 of 5

goyals
Autodesk
Autodesk

Hi @Anonymous,

 

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
0 Likes
Message 3 of 5

ProtoTechSolutions
Participant
Participant

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. 

0 Likes
Message 4 of 5

goyals
Autodesk
Autodesk

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
0 Likes
Message 5 of 5

ProtoTechSolutions
Participant
Participant

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.

0 Likes