[BUG] How to clear up Fusion palette cache?

[BUG] How to clear up Fusion palette cache?

akonovalenko
Contributor Contributor
1,062 Views
4 Replies
Message 1 of 5

[BUG] How to clear up Fusion palette cache?

akonovalenko
Contributor
Contributor

After some time of using my custom palette, Fusion for some reason marks my palettes as Native and do not allow to manipulate with hem thru the script commands. Screenshot_42.png
Screenshot_40.png

even worse I get an error when trying to delete them
Screenshot_41.png

I even try to remove Fusion from my PC then install it back and guess what? - My custom palettes are still there and they are still native 😞

So, my question is: Where Fusion stores information about custom(native) palettes and how that information can be removed?

0 Likes
1,063 Views
4 Replies
Replies (4)
Message 2 of 5

akonovalenko
Contributor
Contributor

Looks like an issue in the NULastDisplayLayout.xml file from
Mac OS:
Macintosh HD > Users > *** > Library > Application Support > Autodesk > Neutron Platform > Options > *** > NULastDisplayedLayout.xml

Windows:
C:\Users\****\AppData\Roaming\Autodesk\Nuetron Platform\Options\***\ NULastDisplayLayout.xml

Which contains a record for my custom palette

            <Area LayoutPattern="Row" Placement="Bottom" Rect="182,1084,617,4">
              <State Size="1491,435" StateType="Absolute"/>
              <Area Contents="Palette" Dockable="True" MinimumSize="150,61" Name="MyTestPalette_3" Placement="Bottom" Rect="0,1080,435,0" Resizable="True" Stretchable="True" Visible="False">
                <State Size="1491,435" StateType="Absolute"/>
                <Parameters Proxy="True"/>
              </Area>
            </Area>

When I removed the file or removed the record from the file - Fusion stops tracking my palette as native, and I can remove it and create a new one. 

Message 3 of 5

akonovalenko
Contributor
Contributor

Does anyone know how to modify or remove NULastDisplayLayout.xml file programmatically from the PY script?

It seems that Fusion 360 creates a new file each time when it closing when all scripts already stopped. So any manipulations with the file before do not have any sense, because the file will be overwritten...

0 Likes
Message 4 of 5

JeromeBriot
Mentor
Mentor

Here is a code that removes the XML file:

import adsk.core, adsk.fusion, adsk.cam, traceback

import os
import platform


def run(context):

    ui = None

    try:

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

        if platform.system() == 'Windows':
            dataPath = os.getenv('APPDATA')
        else:
            dataPath = os.path.join(os.path.expanduser('~'), 'Library', 'Application Support')

        xmlFile = os.path.join(dataPath, 'Autodesk', 'Neutron Platform', 'Options', app.currentUser.userId, 'NULastDisplayedLayout.xml')

        if os.path.exists(xmlFile):
            os.remove(xmlFile)

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

Here is another code that renames the XML file as a backup file (safer):

 

import adsk.core, adsk.fusion, adsk.cam, traceback

import os
import platform


def run(context):

    ui = None

    try:

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

        if platform.system() == 'Windows':
            dataPath = os.getenv('APPDATA')
        else:
            dataPath = os.path.join(os.path.expanduser('~'), 'Library', 'Application Support')

        xmlFile = os.path.join(dataPath, 'Autodesk', 'Neutron Platform', 'Options', app.currentUser.userId, 'NULastDisplayedLayout.xml')

        if os.path.exists(xmlFile):

            bakFile = xmlFile.replace('.xml', '.bak')

            if os.path.exists(bakFile):
                os.remove(bakFile)

            os.rename(xmlFile, bakFile)

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

JeromeBriot
Mentor
Mentor

Hello,

 

I just faced a similar issue. The error message was: "RuntimeError: 3 : Palette with same id has been existed."

 

I had to force Fusion 360 to quit while testing a new add-in. So I think that the file NULastDisplayedLayout.xml became corrupted. The palette I created was not closed properly and the corresponfing <Area> tag in the XML file was not removed.

 

I closed Fusion 360 and I manually removed the section in the XML file. Everything is OK now.

 

 

 

0 Likes