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: 

Duplicated items in material properties

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
j.han97
222 Views, 4 Replies

Duplicated items in material properties

Hi all,

 

I was trying to check the material properties of a body:

body = root_comp.bRepBodies[0] #Take Body1 under rootComponent
mat_prop = body.material.materialProperties #Default material - Steel

Their names were collected to a list and printed:

mat_prop_name = [mp.name for mp in mat_prop]
print(mat_prop_name)

It returned:

['Comments', 'Cost', 'Keynote', 'Keywords', 'Label', 'Manufacturer', 'Mark', 'Model', 'Type', 'URL', 'Class', 'physmat_classification', 'Sharing', 'Behavior', 'Damping Coefficient', 'Density', 'External Material ID', 'Tensile Strength', 'Yield Strength', "Poisson's Ratio", "Poisson's Ratio 12", "Poisson's Ratio 23", "Poisson's Ratio X", "Poisson's Ratio Y", "Poisson's Ratio Z", 'Shear Modulus', 'Shear Modulus 12', 'Shear Modulus X', 'Shear Modulus Y', 'Shear Modulus Z', 'Specific Heat', 'Thermal Conductivity', 'Thermal Conductivity X', 'Thermal Conductivity Y', 'Thermal Conductivity Z', 'Thermal Expansion Coefficient', 'Thermal Expansion Coefficient 1', 'Thermal Expansion Coefficient 2', 'Thermal Expansion Coefficient X', 'Thermal Expansion Coefficient Y', 'Thermal Expansion Coefficient Z', 'Thermally Treated', "Young's Modulus", "Young's Modulus 1", "Young's Modulus 2", "Young's Modulus X", "Young's Modulus Y", "Young's Modulus Z", 'Source', 'Source URL', 'Subclass', 'Sharing', 'Behavior', 'Density', 'Electrical Resistivity', 'Emissivity', 'Permeability', 'Porosity', 'Reflectivity', 'Specific Heat', 'Thermal Conductivity', 'Thermal Conductivity X', 'Thermal Conductivity Y', 'Thermal Conductivity Z', 'Transmits Light', 'Source', 'Source URL', 'Subclass']

 I noticed that there were some duplicated names in this list, e.g. Density, Specific Heat, Behavior etc.

To be exact, there were 11 duplicated items in this list.

len(mat_prop_name)-len(set(mat_prop_name))

This returned 11.

 

May I know the reason behind this?

Thank you so much.

Labels (2)
4 REPLIES 4
Message 2 of 5
kandennti
in reply to: j.han97

Hi @j.han97 .

 

When I tried it, there was no duplication of names. (Win10)

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui: adsk.core.UserInterface = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        body = root.bRepBodies[0]
        mat_prop = body.material.materialProperties

        mat_prop_name = [mp.name for mp in mat_prop]

        print(f'Version: Ver{app.version}')
        print(
            f'len(mat_prop_name)-len(set(mat_prop_name)) -> {len(mat_prop_name)-len(set(mat_prop_name))}\n')

        for mp in mat_prop:
            print(f'{mp.name} : {mp.id}')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Version: Ver2.0.11415
len(mat_prop_name)-len(set(mat_prop_name)) -> 0

Comments : physmat_Comments
Cost : physmat_Cost
Keynote : physmat_Keynote
Keywords : physmat_Keywords
Label : physmat_Label
Manufacturer : physmat_Manufacturer
Mark : physmat_Mark
Model : physmat_Model
Type : physmat_Type
URL : physmat_URL
Class : physmat_class
physmat_classification : physmat_classification
Sharing : common_Shared_Asset
Behavior : structural_Behavior
Damping Coefficient : structural_Damping_coefficient
Density : structural_Density
External Material ID : structural_ExternalMaterialID
Tensile Strength : structural_Minimum_tensile_strength
Yield Strength : structural_Minimum_yield_stress
Poisson's Ratio : structural_Poisson_ratio
Poisson's Ratio 12 : structural_Poisson_ratio_12
Poisson's Ratio 23 : structural_Poisson_ratio_23
Poisson's Ratio X : structural_Poisson_ratio_X
Poisson's Ratio Y : structural_Poisson_ratio_Y
Poisson's Ratio Z : structural_Poisson_ratio_Z
Shear Modulus : structural_Shear_modulus
Shear Modulus 12 : structural_Shear_modulus_12
Shear Modulus X : structural_Shear_modulus_X
Shear Modulus Y : structural_Shear_modulus_Y
Shear Modulus Z : structural_Shear_modulus_Z
Specific Heat : structural_Specific_heat
Thermal Conductivity : structural_Thermal_conductivity
Thermal Conductivity X : structural_Thermal_conductivity_X
Thermal Conductivity Y : structural_Thermal_conductivity_Y
Thermal Conductivity Z : structural_Thermal_conductivity_Z
Thermal Expansion Coefficient : structural_Thermal_expansion_coefficient
Thermal Expansion Coefficient 1 : structural_Thermal_expansion_coefficient_1
Thermal Expansion Coefficient 2 : structural_Thermal_expansion_coefficient_2
Thermal Expansion Coefficient X : structural_Thermal_expansion_coefficient_X
Thermal Expansion Coefficient Y : structural_Thermal_expansion_coefficient_Y
Thermal Expansion Coefficient Z : structural_Thermal_expansion_coefficient_Z
Young's Modulus : structural_Young_modulus
Young's Modulus 1 : structural_Young_modulus_1
Young's Modulus 2 : structural_Young_modulus_2
Young's Modulus X : structural_Young_modulus_X
Young's Modulus Y : structural_Young_modulus_Y
Young's Modulus Z : structural_Young_modulus_Z
Source : structural_source
Source URL : structural_sourceURL
Subclass : structural_subclass
Message 3 of 5
j.han97
in reply to: j.han97

Hi @kandennti ,

 

I have imported some external models in the same session. Do you think this affects the material libraries?

 

I will do a simple check by starting a 'clean' session of Fusion 360 later when I'm free and verify if the problem still exists for me.

Message 4 of 5
kandennti
in reply to: kandennti

@j.han97 .

 

I found out that there are differences between materials.
I don't know why they overlap.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

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

        for materialLibrary in app.materialLibraries:
            for material in materialLibrary.materials:
                materialName = material.name
                mat_prop_name = [mp.name for mp in material.materialProperties]
                overlap = len(mat_prop_name)-len(set(mat_prop_name))
                print(f'{materialName} : {overlap}')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Message 5 of 5
j.han97
in reply to: kandennti

Hi @kandennti ,

 

I used your script and made a little modification to see the differences between the duplicate items.

 

import adsk.core, adsk.fusion, traceback
import itertools


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

        for materialLibrary in app.materialLibraries:
            for material in materialLibrary.materials:
                materialName = material.name
                mat_prop_name = [mp.name for mp in material.materialProperties]
                unique = []
                duplicate = []
                for mp in material.materialProperties:
                    if mp.name not in unique:
                        unique.append(mp.name)
                    elif mp.name not in duplicate:
                        duplicate.append(mp.name)
                
                for dup in duplicate:
                    value = []
                    for mp in material.materialProperties:
                        if mp.name == dup:
                            value.append(mp.value)
                            
                    for (val_1, val_2) in itertools.combinations(value, 2):
                        if val_1 != val_2:
                            print(f'{materialName} - {dup}: {val_1}, {val_2}')
                        

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

For many materials, the only difference is the 'Behavior' property:

 

Behavior: structural_isotropic, thermal_isotropic

 

And for some materials, the duplicate 'Density', 'Thermal Conductivity' properties are also different. E.g.:

 

PVC, Unplasticized - Density: 1290.0, 1400.0
PVC, Unplasticized - Thermal Conductivity: 0.19, 0.251

 

I guess they prepared different values to be used in thermal & structural simulations, but I am totally unsure since I have little knowledge in this aspect.

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