<?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: How to use UserInterface.getText method? in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11388937#M5484</link>
    <description>&lt;P&gt;I couldn't get this to work either, and I talked to someone at Autodesk about it. There ended up being two problems. The first is with the documentation. It says the module name argument should not include the .xml suffix of the file. This is true, but it should also not contain the version. For example, the file "NuCommands10.xml" would be specified as "NuCommands".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second problem is a bug in the function. If Fusion is set to use English, getText will always return what you specified for the default argument. It should work correctly for all other languages.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2022 22:09:30 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2022-08-29T22:09:30Z</dc:date>
    <item>
      <title>How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11382209#M5480</link>
      <description>&lt;P&gt;Please let me know if you know of any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe the UserInterface.getText method can be used to get the language corresponding to the language being activated.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-284B455C-E192-41F7-B5D6-B086BF34E370" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-284B455C-E192-41F7-B5D6-B086BF34E370&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I couldn't find what the module names (xml files) listed in the documentation are.&lt;/P&gt;
&lt;P&gt;I looked in the "StringTable" folder and found it in this path. (Win)&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;C:\Users\&amp;lt;USER_NAME&amp;gt;\AppData\Local\Autodesk\webdeploy\production\&amp;lt;Ver_Folder&amp;gt;\StringTable&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I actually tested with something like this.&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.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface

        txt = ui.getText(
            'DesignVariationsUI10',
            'ActivateGenWorkingModel',
            'NG'
        )

        app.log(txt)
    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;The return value is defaultValue.&lt;BR /&gt;Does anyone have specific code that actually works?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 02:15:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11382209#M5480</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-08-26T02:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11382319#M5481</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'm getting the same result as you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt; ui.getText('Fusion360App10','lclzSafeModeClose','defaultVal')='defaultVal'
 ui.getText('Fusion360App10.xml','lclzSafeModeClose','defaultVal')='defaultVal'
 ui.getText('Fusion360App','lclzSafeModeClose','defaultVal')='defaultVal'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked it in many ways, and none of them worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Don't know what's going in here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;&lt;STRONG&gt;Jorge&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 01:06:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11382319#M5481</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2023-08-29T01:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11382431#M5482</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12364171"&gt;@Jorge_Jaramillo&lt;/a&gt;&amp;nbsp; Thanks for the reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I decided to look into it myself since there was no point in waiting.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 06:08:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11382431#M5482</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-08-26T06:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11384972#M5483</link>
      <description>&lt;P&gt;I have created a langText function that works the same as the getText method I had in mind and have attached it.&lt;BR /&gt;I have also extended it with an optional fourth argument to allow the language to be specified.&lt;BR /&gt;If omitted, it will be the language of the running Fusion360.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is intended to be imported and used.&lt;BR /&gt;I created a test code like this and checked it.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core
from .LanguageTextHelper import langText

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface


        res = langText(
            'DesignVariationsUI10',
            'ActivateGenWorkingModel',
            'NG',
        )
        print(f'function langText:{res}')


        res = langText(
            'DesignVariationsUI10',
            'ActivateGenWorkingModel',
            'NG',
            'de-DE',
        )
        print(f'Specify language as the fourth argument:{res}')


        res = ui.getText(
            'DesignVariationsUI10',
            'ActivateGenWorkingModel',
            'NG',
        )
        print(f'Original getText method:{res}')


        # It is not very desirable, but it is not working, so we override it.
        ui.getText = langText
        res = ui.getText(
            'DesignVariationsUI10',
            'ActivateGenWorkingModel',
            'NG',
        )
        print(f'Overridden getText method:{res}')

    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;Here is the execution result.&lt;BR /&gt;(I am using it in a Japanese environment)&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;function langText:ジェネレーティブ モデルをアクティブ化
Specify language as the fourth argument:Generatives Modell aktivieren
Original getText method:NG
Overridden getText method:ジェネレーティブ モデルをアクティブ化&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also prepared a support function to dump "module" and "id" and the languages that can be used, which I questioned in the getText method.&lt;BR /&gt;You can check them by doing this.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;        # Language
        from .LanguageTextHelper import dumpLanguageNames
        langNames = dumpLanguageNames()
        print(langNames)

        # module
        from .LanguageTextHelper import dumpModuleNames
        moduleNames = dumpModuleNames()
        print(moduleNames)
        moduleNames_es = dumpModuleNames('es-ES')

        # id
        from .LanguageTextHelper import dumpIds
        ids = dumpIds('DesignVariationsUI10')
        print(ids)
        ids_it = dumpIds('DesignVariationsUI10', 'it-IT')&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is of little interest to English speakers, but I hope it will be useful to users of other languages.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2022 14:19:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11384972#M5483</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-08-27T14:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11388937#M5484</link>
      <description>&lt;P&gt;I couldn't get this to work either, and I talked to someone at Autodesk about it. There ended up being two problems. The first is with the documentation. It says the module name argument should not include the .xml suffix of the file. This is true, but it should also not contain the version. For example, the file "NuCommands10.xml" would be specified as "NuCommands".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second problem is a bug in the function. If Fusion is set to use English, getText will always return what you specified for the default argument. It should work correctly for all other languages.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 22:09:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11388937#M5484</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2022-08-29T22:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11389236#M5485</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can confirm what&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;&amp;nbsp;says regarding other languages.&lt;/P&gt;&lt;P&gt;With Spanish it works, without the ".xml" extension and without the version "10" (I wonder where this version number is coming from).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Test script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def get_localized_text():
    try:
        app.log(f"{app.preferences.generalPreferences.userLanguage=}")
        app.log(f"{ui.getText('Fusion360App','lclzSafeModeClose','defaultVal')=}")
        app.log(f"{ui.getText('Fusion360App10','lclzSafeModeClose','defaultVal')=}")
        app.log(f"{ui.getText('Fusion360App10.xml','lclzSafeModeClose','defaultVal')=}")
    except:
        app.log(f'ERROR: {traceback.format_exc()}')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With Spanish user language enabled (it worked now; I made this test before without success):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wtallerdemadera_0-1661824962232.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1109520iB18D0B1C7D5D9BFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="wtallerdemadera_0-1661824962232.png" alt="wtallerdemadera_0-1661824962232.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With English user language enabled:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wtallerdemadera_1-1661825174349.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1109523i7863E61523D22588/image-size/large?v=v2&amp;amp;px=999" role="button" title="wtallerdemadera_1-1661825174349.png" alt="wtallerdemadera_1-1661825174349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;&lt;STRONG&gt;Jorge&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 01:06:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11389236#M5485</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2023-08-29T01:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use UserInterface.getText method?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11389488#M5486</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;&amp;nbsp;Thanks for the reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for showing me how to use it.&lt;BR /&gt;I was not aware that you could not put the version in the module.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have not checked everything, but for the English, I see in the xml file that the value for "translation" is empty.&lt;BR /&gt;I think that is the reason why it returns "defaultValue".&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/1109572iC5A6D98025709F0F/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>Tue, 30 Aug 2022 05:51:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-use-userinterface-gettext-method/m-p/11389488#M5486</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-08-30T05:51:02Z</dc:date>
    </item>
  </channel>
</rss>

