<?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: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon in VRED Forum</title>
    <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340572#M90</link>
    <description>&lt;P&gt;Hi Florian, I think i can help with the first issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6"&gt;1.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;To access variables that are defined in the scope of your script plugin, you've got to inject some variables/attributes to modules.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the script plugin:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
import os

pluginPath = os.path.dirname(__file__)
if not pluginPath in sys.path:
    sys.path.append(pluginPath)

# assumption: your module is called 'mymodulename' 
# prerequisite: 'mymodulename' is located next to the script plugin python file
# prerequisite: 'mymodulename' is a hidden directory or a hidden python file
import mymodulename

class MyPluginClass():
    pass

myPluginClass = MyPluginClass()

mymodulename.myPluginClass = myPluginClass&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Vred (e.g. terminal or variant set scripts)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import mymodulename

print(mymodulename.myPluginClass)
# terminal output: &amp;lt;VREDModule56.MyPluginClass object at 0x00000175B2455E50&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keep in mind that the life-cycle of these attributes have to be considered since they might live longer than the VRED scene contents that they refer to. You can connect to vrMessageService or vrFileIOService signals to tidy up, reset or recreate your objects.&lt;/P&gt;&lt;P&gt;Also, any modules that you import are only imported &lt;STRONG&gt;&lt;EM&gt;once&lt;/EM&gt; &lt;/STRONG&gt;during the lifespan of a VRED runtime. Consequently, don't rely on just an import statement and global statements in the modules, but instead implement start and cleanup functions for your modules and call them from VRED (hotkeys, Qt GUI, singals, VarSets, ...).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6"&gt;2.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I'm struggling to change the plugin icon as well. Before the Qt UI update from PySide2 to PySide6 I was able to change the icon just like that:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;appIconFilePath = os.path.join(os.path.dirname(__file__), "icon.base64.txt")
with open(appIconFilePath, "r") as appiconfile:
    appIcon = appiconfile.read()

# set QtWidget's objectName for easier debugging (empty string by default)
VREDPLUGINWIDGET.setObjectName(f"{appName}")

# manipulate parent elements
dockWidget = VREDPLUGINWIDGET.parent()
mainWindow = dockWidget.parent()

# set name in VRED main menu entry underneath 'Scripts'
dockWidget.setWindowTitle(f"{appName} - version [{appVersion}]")

# add icon from base 64 string that contains the logo
pixmap = QPixmap()
pixmap.loadFromData(QByteArray.fromBase64(str.encode(appIcon)))
dockTitleBarWidgetFrameLabelIcon = QIcon(pixmap)
# dockTitleBarWidgetFrameLabelIcon.setMask(pixmap.mask())
dockWidget.setWindowIcon(dockTitleBarWidgetFrameLabelIcon)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;That solution does not work anymore!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I thought I knew a lot about how to manipulate VRED's Qt interfaces, but I didn't come up with a solution. Sadly, not even a hacky solution worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 10:53:13 GMT</pubDate>
    <dc:creator>clemens_schlicker_audi</dc:creator>
    <dc:date>2025-02-26T10:53:13Z</dc:date>
    <item>
      <title>ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13327152#M89</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two questions regarding VRED ScriptPlugin development:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Is there a way to communicate between two separate ScriptPlugins / a ScriptPlugin and the main application? I'd like to develop a Plugin for dynamically mapping actions to a joystick, some of which are meant to be custom actions of another ScriptPlugin. For this, I need a way to store the mappable actions from the second Plugin in some global variable that I can access from the first Plugin, but it seems that the ScriptPlugins work in an enclosed namespace.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Is there a way to modify a ScriptPlugin's icon? I try to mimic the aesthetic's of VRED's modules as best as I can for coherence, and I couldn't figure out so far how to turn the &lt;EM&gt;&lt;STRONG&gt;M&lt;/STRONG&gt; &lt;/EM&gt;into an actual icon. Especially for pinning multiple ScriptPlugins to the bottom toolbar, it'd be great if they all had descriptive icons, instead of a bunch of &lt;EM&gt;&lt;STRONG&gt;M&lt;/STRONG&gt;&lt;/EM&gt;s next to each other.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Script Plugin Icon.png" style="width: 364px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1468536iA93CFF25369D10DA/image-dimensions/364x234?v=v2" width="364" height="234" role="button" title="Script Plugin Icon.png" alt="Script Plugin Icon.png" /&gt;&lt;/span&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thank you very much in advance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Florian Bruch&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 08:44:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13327152#M89</guid>
      <dc:creator>fbruchD4CS2</dc:creator>
      <dc:date>2025-02-19T08:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340572#M90</link>
      <description>&lt;P&gt;Hi Florian, I think i can help with the first issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6"&gt;1.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;To access variables that are defined in the scope of your script plugin, you've got to inject some variables/attributes to modules.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the script plugin:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import sys
import os

pluginPath = os.path.dirname(__file__)
if not pluginPath in sys.path:
    sys.path.append(pluginPath)

# assumption: your module is called 'mymodulename' 
# prerequisite: 'mymodulename' is located next to the script plugin python file
# prerequisite: 'mymodulename' is a hidden directory or a hidden python file
import mymodulename

class MyPluginClass():
    pass

myPluginClass = MyPluginClass()

mymodulename.myPluginClass = myPluginClass&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Vred (e.g. terminal or variant set scripts)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import mymodulename

print(mymodulename.myPluginClass)
# terminal output: &amp;lt;VREDModule56.MyPluginClass object at 0x00000175B2455E50&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keep in mind that the life-cycle of these attributes have to be considered since they might live longer than the VRED scene contents that they refer to. You can connect to vrMessageService or vrFileIOService signals to tidy up, reset or recreate your objects.&lt;/P&gt;&lt;P&gt;Also, any modules that you import are only imported &lt;STRONG&gt;&lt;EM&gt;once&lt;/EM&gt; &lt;/STRONG&gt;during the lifespan of a VRED runtime. Consequently, don't rely on just an import statement and global statements in the modules, but instead implement start and cleanup functions for your modules and call them from VRED (hotkeys, Qt GUI, singals, VarSets, ...).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="6"&gt;2.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I'm struggling to change the plugin icon as well. Before the Qt UI update from PySide2 to PySide6 I was able to change the icon just like that:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;appIconFilePath = os.path.join(os.path.dirname(__file__), "icon.base64.txt")
with open(appIconFilePath, "r") as appiconfile:
    appIcon = appiconfile.read()

# set QtWidget's objectName for easier debugging (empty string by default)
VREDPLUGINWIDGET.setObjectName(f"{appName}")

# manipulate parent elements
dockWidget = VREDPLUGINWIDGET.parent()
mainWindow = dockWidget.parent()

# set name in VRED main menu entry underneath 'Scripts'
dockWidget.setWindowTitle(f"{appName} - version [{appVersion}]")

# add icon from base 64 string that contains the logo
pixmap = QPixmap()
pixmap.loadFromData(QByteArray.fromBase64(str.encode(appIcon)))
dockTitleBarWidgetFrameLabelIcon = QIcon(pixmap)
# dockTitleBarWidgetFrameLabelIcon.setMask(pixmap.mask())
dockWidget.setWindowIcon(dockTitleBarWidgetFrameLabelIcon)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;That solution does not work anymore!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I thought I knew a lot about how to manipulate VRED's Qt interfaces, but I didn't come up with a solution. Sadly, not even a hacky solution worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 10:53:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340572#M90</guid>
      <dc:creator>clemens_schlicker_audi</dc:creator>
      <dc:date>2025-02-26T10:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340721#M91</link>
      <description>&lt;P&gt;Hi, in VRED 2025 you can set the window icon in the constructor of the script plugin, see the attached example file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;self.parent.setWindowTitle("My custom SimpleExample title")&lt;BR /&gt;self.parent.setWindowIcon(icon)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is an internal mechanism that will forward this to the dock widget.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 12:14:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340721#M91</guid>
      <dc:creator>sinje_thiedemann</dc:creator>
      <dc:date>2025-02-26T12:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340843#M92</link>
      <description>&lt;P&gt;Hi Clemens,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is fantastic, thank you so much! Your solution for my first question is exactly what I was hoping and looking for. Having hidden folders and python files within the ScriptPlugins folder is also a very helpful tip and something I hadn't thought of, which will also help me a lot with my plugin development. Thank you for the heads up about using start and cleanup functions as well, I'll make sure to look into that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Florian&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 13:05:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340843#M92</guid>
      <dc:creator>fbruchD4CS2</dc:creator>
      <dc:date>2025-02-26T13:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340898#M93</link>
      <description>&lt;P&gt;Hi Sinje,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was still developing in VRED 2024, I can confirm that your solution works for VRED 2025! Just one thing though, changing the Window Title seems to interfere with the functionality of pinning the module to the bottom toolbar. I can only pin the Simple Example to the toolbar if I comment out the line where the window title is changed. Still, your answer helped me a lot, thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Florian&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 13:17:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13340898#M93</guid>
      <dc:creator>fbruchD4CS2</dc:creator>
      <dc:date>2025-02-26T13:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13342869#M94</link>
      <description>&lt;P&gt;Hello Sinje,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution you suggest with "&lt;SPAN&gt;self.parent.setWindowTitle" only seams to update at launch-time of VRED - correct? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I.e., there is still no way of setting the plugin window title at run-time of VRED (which was possible before Release of 2024)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I did discuss this request with Marcus back then and he promised to log the request. Any progress on this?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Our use case: We load a database in to our plugin and then the user should see the loaded database file name in the plug-in window title just like the vpb file name shown in the main window title. This worked perfectly fine with VRED 2023.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks. Ingolf&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 10:59:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13342869#M94</guid>
      <dc:creator>ir</dc:creator>
      <dc:date>2025-02-27T10:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13349116#M95</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7811645"&gt;@fbruchD4CS2&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;for 2024.2 I found this snippet (untested):&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;moduleWidget = self.parent.parentWidget().parentWidget().parentWidget()
moduleWidget.setWindowTitle("My custom SimpleExample title")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pin to quick access bar: That worked for me in 2025.1, though the name displayed below the icon is not customizable. Ah, I see the "pin" toggle button next in the menu action in the Scripts menu does not work, I used the menu on the module icon: &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sinje_thiedemann_0-1741006305131.png" style="width: 427px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1473178i041E3CBBF7098990/image-dimensions/427x274?v=v2" width="427" height="274" role="button" title="sinje_thiedemann_0-1741006305131.png" alt="sinje_thiedemann_0-1741006305131.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1649468"&gt;@ir&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The self.parent.setWindowTitle in 2025 was the solution that was implemented after your request. But I can confirm that it only works reliably at launch-time.&amp;nbsp; I created a ticket to fully support changing it dynamically. I found the title can be changed after VRED has started but this also somehow sets the icon to a VRED logo; and after using Reload Script Plugins the setWindowTitle has no effect any more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2025 12:57:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13349116#M95</guid>
      <dc:creator>sinje_thiedemann</dc:creator>
      <dc:date>2025-03-03T12:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13349187#M96</link>
      <description>&lt;P&gt;Hello Sinje,&lt;/P&gt;&lt;P&gt;Thanks so much for creating a ticket to fully support&amp;nbsp;&lt;SPAN&gt;changing the window title dynamically! Would be fantastic if you could share the solution here when implemented. Take care!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ingolf&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2025 13:35:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13349187#M96</guid>
      <dc:creator>ir</dc:creator>
      <dc:date>2025-03-03T13:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptPlugin Questions: 1. Shared Namespace, 2. Plugin Icon</title>
      <link>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13905280#M11929</link>
      <description>&lt;P&gt;Hi, thanks for the solutions, it's very helpful.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Did any of you found a way to add the widget to quick access bar from script ?&lt;BR /&gt;Or to dock it in a native way ?&lt;/P&gt;&lt;P&gt;It's possible to do it in a hacky way using Qt but then it's not really recognized by VRED (the look is weird and do not react so well)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;BR /&gt;&lt;BR /&gt;EDIT: I found out we can save the workspace so I think it's the intended way&lt;BR /&gt;Now the final thing missing to have it behave like an official module of VRED would be to have the icon going orange when the tab is open, any clue ?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 06:49:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vred-forum/scriptplugin-questions-1-shared-namespace-2-plugin-icon/m-p/13905280#M11929</guid>
      <dc:creator>altarfinch</dc:creator>
      <dc:date>2025-11-17T06:49:32Z</dc:date>
    </item>
  </channel>
</rss>

