API To Get Material Type

API To Get Material Type

isocam
Collaborator Collaborator
617 Views
2 Replies
Message 1 of 3

API To Get Material Type

isocam
Collaborator
Collaborator

Can anybody help?

 

Does anybody know how to display (in a message box for testing only) the Fusion 360 part material?

 

Say I have a part and I assign Stainless Steel to that part, I need to be able to display the material in a message box.

 

This is just a small part of a larger project that I an working on.

 

Many thanks in advance!!!!

 

Darren

0 Likes
618 Views
2 Replies
Replies (2)
Message 2 of 3

erik
Advocate
Advocate

I am not entirely sure what you want, but if it is the name of the material applied to a component its usually the same as the appearance name which can be found using the following code

appearanceName = occurrence.appearance.name

and displayed using the following code

app = adsk.core.Application.get()
ui  = app.userInterface
ui.messageBox(appearanceName)

Please reply if this is what you want or something else is desired? 🙂

 

- Erik

0 Likes
Message 3 of 3

wegienka
Explorer
Explorer

Given a component in:

 

Ptr<Component> comp;

 

You can access the material properties using:

 

Ptr<Material> mat = comp->material();

string matname = mat->name();

 

0 Likes