<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Duplicated items in material properties in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765430#M7497</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used your script and made a little modification to see the differences between the duplicate items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For many materials, the only difference is the 'Behavior' property:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Behavior: structural_isotropic, thermal_isotropic&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;And for some materials, the duplicate 'Density', 'Thermal Conductivity' properties are also different. E.g.:&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;PVC, Unplasticized - Density: 1290.0, 1400.0
PVC, Unplasticized - Thermal Conductivity: 0.19, 0.251&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;I guess they prepared different values to be used in thermal &amp;amp; structural simulations, but I am totally unsure since I have little knowledge in this aspect.&lt;/DIV&gt;</description>
    <pubDate>Thu, 18 Nov 2021 07:17:55 GMT</pubDate>
    <dc:creator>j.han97</dc:creator>
    <dc:date>2021-11-18T07:17:55Z</dc:date>
    <item>
      <title>Duplicated items in material properties</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765020#M7493</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to check the material properties of a body:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;body = root_comp.bRepBodies[0] #Take Body1 under rootComponent
mat_prop = body.material.materialProperties #Default material - Steel&lt;/LI-CODE&gt;&lt;P&gt;Their names were collected to a list and printed:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;mat_prop_name = [mp.name for mp in mat_prop]
print(mat_prop_name)&lt;/LI-CODE&gt;&lt;P&gt;It returned:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;['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']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I noticed that there were some duplicated names in this list, e.g. Density, Specific Heat, Behavior etc.&lt;/P&gt;&lt;P&gt;To be exact, there were 11 duplicated items in this list.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;len(mat_prop_name)-len(set(mat_prop_name))&lt;/LI-CODE&gt;&lt;P&gt;This returned 11.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May I know the reason behind this?&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 01:40:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765020#M7493</guid>
      <dc:creator>j.han97</dc:creator>
      <dc:date>2021-11-18T01:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicated items in material properties</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765139#M7494</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11275785"&gt;@j.han97&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I tried it, there was no duplication of names. (Win10)&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# 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)) -&amp;gt; {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()))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Version: Ver2.0.11415
len(mat_prop_name)-len(set(mat_prop_name)) -&amp;gt; 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&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Nov 2021 03:19:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765139#M7494</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2021-11-18T03:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicated items in material properties</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765184#M7495</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have imported some external models in the same session. Do you think this affects the material libraries?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 04:08:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765184#M7495</guid>
      <dc:creator>j.han97</dc:creator>
      <dc:date>2021-11-18T04:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicated items in material properties</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765190#M7496</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11275785"&gt;@j.han97&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found out that there are differences between materials.&lt;BR /&gt;I don't know why they overlap.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;# 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()))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Nov 2021 04:12:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765190#M7496</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2021-11-18T04:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicated items in material properties</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765430#M7497</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used your script and made a little modification to see the differences between the duplicate items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For many materials, the only difference is the 'Behavior' property:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Behavior: structural_isotropic, thermal_isotropic&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;And for some materials, the duplicate 'Density', 'Thermal Conductivity' properties are also different. E.g.:&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;PVC, Unplasticized - Density: 1290.0, 1400.0
PVC, Unplasticized - Thermal Conductivity: 0.19, 0.251&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;I guess they prepared different values to be used in thermal &amp;amp; structural simulations, but I am totally unsure since I have little knowledge in this aspect.&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Nov 2021 07:17:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/duplicated-items-in-material-properties/m-p/10765430#M7497</guid>
      <dc:creator>j.han97</dc:creator>
      <dc:date>2021-11-18T07:17:55Z</dc:date>
    </item>
  </channel>
</rss>

