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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Material issue faced when using Fusion API

Message 1 of 7
470 Views, 6 Replies

Material issue faced when using Fusion API

We are trying to export the material used in fusion to the output file.
When multiple color is applied on model in fusion in output file we get one random color applied to whole body.
Similarly we are trying to export texture, multiple texture applied on body is not exported in output file.
Please look into the issue and guide us through if we are doing something wrong.

Message 2 of 7
in reply to: adn.developer

It is not clear to me what you are trying to accomplish.  Some of that is because of terminology.  Fusion has materials and appearances.  A material has physical properties like density and Poisson's ratio that define it's physical characteristics.  A material also has appearance information that defines how the object will look.  You mentioned materials but then it seems you're actually talking about appearances.  Are you exporting the model as a mesh or some other format?  What will you be using the data for?


A material can be assigned to a component and all of the bodies within that component will use the material.  A material can also be assigned to a body, which will override the material assigned to its parent component.


By default, a body will display using the appearance associated with the material assigned to the body of its parent component.  However, you can override the material appearance and assign another appearance.  Appearances can be assigned to components, bodies, and even individual faces.  The object at the lowest level that has an appearance assigned will override any appearance assignments at higher levels.  For example, an appearance assigned to a body will override the appearance assigned to the component and an appearance assigned to a face will override the body appearance.



Brian Ekins
Inventor and Fusion 360 API Expert
Message 3 of 7
in reply to: BrianEkins

We are exporting the mesh data to the output file, we want to get data of color and texture present in the model.
Using appearance the color/texture information is retrieved.
The issue faced is if model have multiple color/texture are present on the model we are getting value of only one color/texture from the list.
I hope i was able to clear the confusing about the issue faced.
Here is the link in which i have provided the small demo screen recorded video to illustrate the issue.
Looking forward to hear from you.
Thank you in advance for the help.

Message 4 of 7
in reply to: adn.developer

I've attached a simple model with three different appearances applied.



The script below gets the appearances from the model and writes out information into the text window.

def run(context):
    app: adsk.core.Application = adsk.core.Application.get()
    ui = app.userInterface

        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent
        occ1: adsk.fusion.Occurrence = root.occurrences[0]
        occ2: adsk.fusion.Occurrence = root.occurrences[1]
        occ3: adsk.fusion.Occurrence = root.occurrences[2]
        body1: adsk.fusion.BRepBody = occ1.bRepBodies[0]
        body2: adsk.fusion.BRepBody = occ2.bRepBodies[0]
        body3: adsk.fusion.BRepBody = occ3.bRepBodies[0]
        WriteToTextWindow('   body: ' + + ', ' +
        WriteToTextWindow('   color: ' + AppearanceColor(body1.appearance))
        WriteToTextWindow('   body: ' + + ', ' +
        WriteToTextWindow('   color: ' + AppearanceColor(body2.appearance))
        WriteToTextWindow('   body: ' + + ', ' +
        WriteToTextWindow('   color: ' + AppearanceColor(body3.appearance))
        if ui:

def AppearanceColor(appearance: adsk.core.Appearance):
    color: adsk.core.Color = appearance.appearanceProperties.itemById('wood_early_color').value
    return str( + ', ' + str( + ', ' + str(  


Here are the results:

   body: Green, 3D Walnut - Green
   color: 46, 167, 30
   body: Blue, 3D Maple - Yellow
   color: 189, 167, 16
   body: Red, 3D Pine - Red
   color: 159, 5, 5


Fusion uses an Autodesk specific renderer and materials are defined using a proprietary definition.  This makes it difficult to transfer materials from Fusion to other renderers.  In the example program, I'm getting the appearance associated with each body.  Appearances are defined by a set of properties.  In this case, the property that primarily defined the color is a property whose ID is "wood_early_color".  Depending on the settings of the properties, the primary color could be defined by a different property.


There are five different types of appearances; opaque, metal, transparent, layered, and 3D wood.  Each type of appearance will have a consistent set of properties.  The script below dumps out all of the appearances in the active design and shows the values of most of the properties associated with the appearance.  The first value of "Material Type" indicates which of the 5 types of appearances it is.


def run(context):
    app: adsk.core.Application = adsk.core.Application.get()
    ui = app.userInterface
    des: adsk.fusion.Design = app.activeProduct

    filename = 'C:/Temp/AppearanceInfo.txt'
    f = open(filename, 'w')

    appearance: adsk.core.Appearance = None
    for appearance in des.appearances:
        f.write('Appearance ' + + ' (' + + ')\n')

        prop: adsk.core.Property
        for prop in appearance.appearanceProperties:
                f.write('   Property ' + + ', ' + + ', ' + prop.objectType + '\n')
                f.write('       Value: ' + AppearanceValueAsString(prop) + '\n')
                f.write('   *** Failed')



    ui.messageBox('Finished writing appearance info to C:/Temp/AppeaeranceInfo.txt')

def AppearanceValueAsString(appearanceProp):
    if appearanceProp.objectType == adsk.core.IntegerProperty.classType():
        intProp: adsk.core.IntegerProperty = appearanceProp
        return str(intProp.value)
    elif appearanceProp.objectType == adsk.core.StringProperty.classType():
        stringProp: adsk.core.StringProperty = appearanceProp
        return str(stringProp.value)
    elif appearanceProp.objectType == adsk.core.ColorProperty.classType():
        colorProp: adsk.core.ColorProperty = appearanceProp
        return str( + ', ' + str( + ', ' + str(
    elif appearanceProp.objectType == adsk.core.FloatProperty.classType():
        floatProp: adsk.core.FloatProperty = appearanceProp
        return str(floatProp.value) 
    elif appearanceProp.objectType == adsk.core.BooleanProperty.classType():
        boolProp: adsk.core.BooleanProperty = appearanceProp
        return str(boolProp.value) 
        return '???'
Brian Ekins
Inventor and Fusion 360 API Expert
Message 5 of 7


Thank you for the response.
We have tried the sample code provided by you in our program.
The code did not yield the desired output for us.

Here I'm pasting some image will will give the clear understanding of what issue we are facing.

Here is the code snippet which get the list of appearance from the design and write the name of the appearance in the text file.


Here is the image of design file, i have highlighted the material list used in the design.
Here is the output text file in which the list of material is written using the code snippet above.
As we can see there are repetition of same material in the loop.
From the list of appearance we are able to get only the first material present in the list


Please look into the isuse and provide the solution for the same.
Thank you in advance


Message 6 of 7

Sorry, I'm so late to respond.  I somehow missed this.
Is it possible to post the f3d for that design here or you can send it to me directly using the email in my signature.  Was the file imported from another system?  At one time I believe there was an appearance issue with imported files.  Either way, I can do some testing and if I find what looks like a Fusion bug, pass it onto Autodesk.

Brian Ekins
Inventor and Fusion 360 API Expert
Message 7 of 7
in reply to: BrianEkins

I was given your sample file and wrote another little script to be able to visualize what's going on.  There is a bug in Fusion with how appearances are identified internally.  As a result, it can return the wrong appearance, which is what you're seeing.  It took me a bit to find it because the first thing I did was rename the appearances in your sample so my output was easier to read.  It turns out that making any edit to an appearance does something to correct the problem for that appearance.


I'm working with Autodesk to log the bug so they can prioritize it.

Brian Ekins
Inventor and Fusion 360 API Expert

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