<?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: Legacy Appearance Library is the only one that works but I can't get it in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11553794#M5131</link>
    <description>&lt;P&gt;&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 think your code looks correct. I am more sure that it is Fusion bug that you cannot change the image if not using the Legacy Material. Even if you use Legacy Material, you have to manually create one to the Favorite category before you can programmatically change the material. I hope Fusion knows about this bug.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 15:07:00 GMT</pubDate>
    <dc:creator>sophiadoan</dc:creator>
    <dc:date>2022-11-15T15:07:00Z</dc:date>
    <item>
      <title>Legacy Appearance Library is the only one that works but I can't get it</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11533135#M5129</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;From help in this forum, the process of working with appearance is:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;- Copy an appearance from a material library to the design&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;- Making changes (color, texture etc.) to the copied version&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;- Apply the copied version to a body or face.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I tried to manually (not programmatically) copy "Hardwood" from&amp;nbsp;"Legacy Appearance Library"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and then programmatically&amp;nbsp;changeTextureImage with a JPEG image, this works.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sophiadoan_0-1667664893880.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1136588i4D90E21D80CA69F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sophiadoan_0-1667664893880.png" alt="sophiadoan_0-1667664893880.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If the same is done with "Mahogany" from&amp;nbsp;"Fusion 360 Appearance Library", it does not work (manually or programmatically).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;It failed at getting texture (value None returned):&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;prop&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;copiedMahogany&lt;/SPAN&gt;&lt;SPAN&gt;.appearanceProperties.itemByName(&lt;/SPAN&gt;&lt;SPAN&gt;'Image'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;image&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;adsk&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;core&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;AppearanceTextureProperty&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;cast&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;prop&lt;/SPAN&gt;&lt;SPAN&gt;) #OK&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;texture&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;adsk&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;core&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;AppearanceTexture&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;cast&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;image&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;SPAN&gt;) #return None&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sophiadoan_2-1667664987302.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1136591iE06F93EFACC95765/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sophiadoan_2-1667664987302.png" alt="sophiadoan_2-1667664987302.png" /&gt;&lt;/span&gt;&lt;P&gt;So I tried to programmatically getting "Hardwood" from&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"Legacy Appearance Library", it won't let me do it.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;matLib&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;app&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;materialLibraries&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;itemByName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Legacy Appearance Library"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;matLib value is None&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;but&amp;nbsp;matLib = app.materialLibraries.itemByName("Fusion 360 Appearance Library")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return ok,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;I then programmatically copy an item "Mahogany" from "Fusion 360 Appearance Library" to design and&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;changeTextureImage to a JPEG image , texture as shown above return None.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;I am stuck. I hope this is not Fusion bug. Please help cause I would be funny to ask user to manually create an appearance from the "Legacy Appearance Library".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 05 Nov 2022 16:30:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11533135#M5129</guid>
      <dc:creator>sophiadoan</dc:creator>
      <dc:date>2022-11-05T16:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Legacy Appearance Library is the only one that works but I can't get it</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11545651#M5130</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4278890"&gt;@sophiadoan&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a script like this and tried it out.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

CLANE_MATERIAL_NAME = 'test'
IMAGE_PATH = r'C:\temp\1.png'

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct

        # remove test appearance
        appearance_temp: adsk.core.Material = des.appearances.itemByName(CLANE_MATERIAL_NAME)
        if appearance_temp:
            appearance_temp.deleteMe()

        # Fusion 360 Appearance Library - BA5EE55E-9982-449B-9D66-9F036540E140
        matLib: adsk.core.MaterialLibrary = app.materialLibraries.itemById('BA5EE55E-9982-449B-9D66-9F036540E140')

        # Mahogany - Prism-140
        appearance_Prism_140: adsk.core.Appearance = matLib.appearances.itemById('Prism-140')
        dump_appearance_image_path('Prism_140', appearance_Prism_140)

        # clone appearance
        appearance_Clone: adsk.core.Appearance = des.appearances.addByCopy(appearance_Prism_140, CLANE_MATERIAL_NAME)
        dump_appearance_image_path('Exec Clone', appearance_Clone)

        # chenge Image path
        appearanceTextureProp: adsk.core.AppearanceTextureProperty = appearance_Clone.appearanceProperties.itemById('surface_normal')
        appearanceTexture: adsk.core.AppearanceTexture = appearanceTextureProp.value
        fileNameProp: adsk.core.FilenameProperty = appearanceTexture.properties.itemById('bumpmap_Bitmap')
        fileNameProp.value = IMAGE_PATH
        
        dump_appearance_image_path('Change Image', appearance_Clone)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def dump_appearance_image_path(msg: str, appearance: adsk.core.Appearance):
    appearanceTextureProp: adsk.core.AppearanceTextureProperty = appearance.appearanceProperties.itemById('surface_normal')
    appearanceTexture: adsk.core.AppearanceTexture = appearanceTextureProp.value
    fileNameProp: adsk.core.FilenameProperty = appearanceTexture.properties.itemById('bumpmap_Bitmap')

    dump(f'{msg} : {fileNameProp.value}')

def dump(s):
    adsk.core.Application.get().log(f'{s}')
    print(s)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My script may be wrong, but as a result I could not replace the image.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the way to get the path of the appearance image file is the dump_appearance_image_path function, am I wrong?&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;def dump_appearance_image_path(msg: str, appearance: adsk.core.Appearance):
    appearanceTextureProp: adsk.core.AppearanceTextureProperty = appearance.appearanceProperties.itemById('surface_normal')
    appearanceTexture: adsk.core.AppearanceTexture = appearanceTextureProp.value
    fileNameProp: adsk.core.FilenameProperty = appearanceTexture.properties.itemById('bumpmap_Bitmap')

    dump(f'{msg} : {fileNameProp.value}')&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I looked at the output, it is different from the Mahogany image path cloned in the GUI, so I was not sure what was correct.(Ver&amp;nbsp;&lt;SPAN&gt;2.0.14793&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1138602iBD54CD9904B42CAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 08:39:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11545651#M5130</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-11-11T08:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Legacy Appearance Library is the only one that works but I can't get it</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11553794#M5131</link>
      <description>&lt;P&gt;&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 think your code looks correct. I am more sure that it is Fusion bug that you cannot change the image if not using the Legacy Material. Even if you use Legacy Material, you have to manually create one to the Favorite category before you can programmatically change the material. I hope Fusion knows about this bug.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 15:07:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/legacy-appearance-library-is-the-only-one-that-works-but-i-can-t/m-p/11553794#M5131</guid>
      <dc:creator>sophiadoan</dc:creator>
      <dc:date>2022-11-15T15:07:00Z</dc:date>
    </item>
  </channel>
</rss>

