<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dialog Menu]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have two dialogs in different python scripts and I would like to join them in a single python script so the user via buttons can choose what dialog to show.</p>
<p dir="auto">I tried searching the forums as well as reading the documentation but I have not been able to find a starting guide to solve this issue.</p>
<p dir="auto">Does anyone have an idea how I could achieve a solution to this problem?</p>
<p dir="auto">Thanks so much for your time.</p>
]]></description><link>http://developers.maxon.net/forum/topic/14403/dialog-menu</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 21:48:07 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/14403.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Feb 2023 10:36:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dialog Menu on Thu, 09 Mar 2023 07:48:50 GMT]]></title><description><![CDATA[<p dir="auto">Creating an instance for each subdialog solved the issue thank you so much.</p>
]]></description><link>http://developers.maxon.net/forum/post/70889</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70889</guid><dc:creator><![CDATA[Joel]]></dc:creator><pubDate>Thu, 09 Mar 2023 07:48:50 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog Menu on Thu, 09 Mar 2023 08:31:21 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/joel">@<bdi>joel</bdi></a>,</p>
<p dir="auto">you are running there in a fringe ownership error of the dialog object. You must create a dummy reference to the dialog before you overwrite the instance bound reference <code>self.subDialog</code> to avoid a race condition between the GC and C4D which is still using the dialog. Or what I would recommend - keep two dialog instances around, as this code looks then more sane to me.</p>
<p dir="auto">Find below a fix.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
<pre><code>import typing
import c4d
from c4d import gui

ID_SUBDIALOG = 10000
ID_Dialog1_BUTTON = 10001
ID_Dialog2_BUTTON = 10002

class Dialog1(c4d.gui.SubDialog):
    def CreateLayout(self):
        self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 1")
        return True

class Dialog2(c4d.gui.SubDialog):
    def CreateLayout(self):
        self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 2")
        return True

class MainDialog(c4d.gui.GeDialog):
    """
    """
    def __init__(self) -&gt; None:
        """
        """
        # You made your subDialog attribute class bound but then later used it as instance bound.
        # I assume that was an oversight and you did not want the sub dialog to be class bound but
        # instance bound.
        self._dlg1: Dialog1 = Dialog1() # Dialog instance for type 1
        self._dlg2: Dialog2 = Dialog2() # Dialog instance for type 2

    def CreateLayout(self):
        self.GroupBegin(0, c4d.BFH_SCALEFIT, 2)
        self.AddButton(ID_Dialog1_BUTTON, c4d.BFH_SCALEFIT, name="Dialog1")
        self.AddButton(ID_Dialog2_BUTTON, c4d.BFH_SCALEFIT, name="Dialog2")
        self.GroupEnd()
        self.AddSubDialog(ID_SUBDIALOG, c4d.BFH_SCALEFIT, 100, 100)
        return True

    def Command(self, mid, msg):
        # Switch the dialog based on which button has been pressed.
        if mid in (ID_Dialog1_BUTTON, ID_Dialog2_BUTTON):
            self.AttachSubDialog(self._dlg1 
                                 if mid == ID_Dialog1_BUTTON
                                 else self._dlg2, ID_SUBDIALOG)
            print(self.LayoutChanged(ID_SUBDIALOG))
        return True

if __name__=='__main__':
    dlg = MainDialog()
    dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=900, xpos=-2, ypos=-2)
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/70885</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70885</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Thu, 09 Mar 2023 08:31:21 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog Menu on Wed, 08 Mar 2023 17:20:39 GMT]]></title><description><![CDATA[<p dir="auto">I tried using the subdialog as the github example shows. If I just want to do one subdialog change the github example that <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mogh">@<bdi>mogh</bdi></a> posted works just find. However when I add another button so I can switch between the subdialogs the Dialog does not update.</p>
<p dir="auto">The code I used is a bit modified from the github but more or less the same:</p>
<pre><code>import c4d
from c4d import gui

ID_SUBDIALOG = 10000
ID_Dialog1_BUTTON = 10001
ID_Dialog2_BUTTON = 10002

class Dialog1(c4d.gui.SubDialog):
    def CreateLayout(self):
        self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 1")
        return True

class Dialog2(c4d.gui.SubDialog):
    def CreateLayout(self):
        self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 2")
        return True

class MainDialog(c4d.gui.GeDialog):
    subDialog = Dialog1()
    
    def CreateLayout(self):
        self.GroupBegin(0, c4d.BFH_SCALEFIT, 2)
        self.AddButton(ID_Dialog1_BUTTON, c4d.BFH_SCALEFIT, name="Dialog1")
        self.AddButton(ID_Dialog2_BUTTON, c4d.BFH_SCALEFIT, name="Dialog2")
        self.GroupEnd()
        
        self.AddSubDialog(ID_SUBDIALOG, c4d.BFH_SCALEFIT, 100, 100)
        self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
        
        return True
    
    def Command(self, mid, msg):
        if mid == ID_Dialog1_BUTTON:
            self.subDialog = Dialog1()
            self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
            print(self.LayoutChanged(ID_SUBDIALOG))
        if mid == ID_Dialog2_BUTTON:
            self.subDialog = Dialog2()
            self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
            print(self.LayoutChanged(ID_SUBDIALOG))
        return True

if __name__=='__main__':
    dlg = MainDialog()
    dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=900, xpos=-2, ypos=-2)
</code></pre>
<p dir="auto">When I click the buttons the first button click from either button the LayoutChanged returns True but on the second button click from either button returns False.</p>
<p dir="auto">What am I doing wrong?</p>
]]></description><link>http://developers.maxon.net/forum/post/70883</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70883</guid><dc:creator><![CDATA[Joel]]></dc:creator><pubDate>Wed, 08 Mar 2023 17:20:39 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog Menu on Wed, 01 Mar 2023 10:42:50 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/joel">@<bdi>joel</bdi></a>,</p>
<p dir="auto">thank you for reaching out to us. I am a bit confused about the nature of your question; when you have implemented two dialogs, you should be able to do this on your own.</p>
<p dir="auto">Interpreting your question in the most straight forward way, you have two dialogs <em>A</em> and <em>B</em> and want the user to be able to open either of them from a single script. You then must simply implement a dialog <em>C</em> with two buttons which open the respective dialogs. When you attach the dialog instances <em>A</em> and <em>B</em> to <em>C</em> you can also add some logic which would prevent users from opening multiple instances of <em>A</em> or <em>B</em> or opening <em>A</em> and <em>B</em> at the same time.</p>
<p dir="auto">Then there are multiple interpretations of your question which are less literal.</p>
<ul>
<li>As pointed out by <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mogh">@<bdi>mogh</bdi></a> (thanks!), there is the concept of sub-dialogs in Cinema 4D. This effectively just means that the content of one ore multiple dialogs can be rendered within a hosting dialog. See <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html#GeDialog.AddSubDialog" target="_blank" rel="noopener noreferrer nofollow ugc">GeDialog.AddSubDialog</a> for a point of entry to the concept in the API. There are also <a href="https://github.com/search?q=org%3APluginCafe+AddSubDialog&amp;type=code" target="_blank" rel="noopener noreferrer nofollow ugc">two C++ and two Python code examples</a> making use of this concept.</li>
<li>There is also the tab gadget with which you can structure larger groups of disjunct UI elements in a singular dialog. See <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html#GeDialog.TabGroupBegin" target="_blank" rel="noopener noreferrer nofollow ugc">GeDialog.TabGroupBegin</a> for a point of entry. There exist only <a href="https://github.com/search?q=org%3APluginCafe+TabGroupBegin&amp;type=code" target="_blank" rel="noopener noreferrer nofollow ugc">C++ Code examples</a> for this gadget, although using it in Python is perfectly possible.<br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1677664620387-3bb20552-58ca-4fce-b551-ff923ba3ab3a-image.png" alt="3bb20552-58ca-4fce-b551-ff923ba3ab3a-image.png" class=" img-fluid img-markdown" /></li>
<li>You could also use three layout groups in a singular dialog, let's call them <em>A</em>, <em>B</em>, and <em>C</em>. <em>A</em> and <em>B</em> contain the layout of two dialogs as in the prior example. <em>C</em> also contains two buttons as in the prior example. You then add the groups in the order <em>C</em>, <em>A</em>, and <em>B</em> to a singular dialog. When the user presses a button in <em>C</em>, you hide and unhide the groups <em>A</em> and <em>B</em> using <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html#GeDialog.HideElement" target="_blank" rel="noopener noreferrer nofollow ugc">GeDialog.HideElement</a>, so that the user sees only one of them at a time.
<ul>
<li>You can also dynamically rebuild the whole GUI at runtime, but that should not be necessary in this case. Find an example <a href="https://developers.maxon.net/forum/topic/14256/python-plugin-gui-tutorial/3" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</li>
</ul>
</li>
<li>This is more of an academic point, since it seems unlikely to me that you are using a dialog resource. But when you have defined two dialog resources <em>RA</em> and <em>RB</em>, nothing prevents you from (a.) loading them both into their seperate dialog but also (b.) into a singular dialog by simply calling <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.gui/GeDialog/index.html#GeDialog.LoadDialogResource" target="_blank" rel="noopener noreferrer nofollow ugc">GeDialog.LoadDialogResource</a> twice in succession.</li>
</ul>
<table class="table table-bordered table-striped">
<tbody>
<tr>
<td><img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/26a0.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--warning" style="height:23px;width:auto;vertical-align:middle" title=":warning:" alt="⚠" /> Script Manager scripts are not meant to have extensive GUIs. While one can make things work, it is easier and safer to wrap things into a <code>CommandData</code> plugin. You will need a plugin ID which you can get here on the forum with the plug icon in the top menu bar. The plugin itself is then straight forward, you can ignore the <code>CommandData</code> stuff and reuse the code in the <a href="https://developers.maxon.net/forum/topic/14256/python-plugin-gui-tutorial/3" target="_blank" rel="noopener noreferrer nofollow ugc">dynamic dialog GUI</a> example which I have posted above; the only thing you would have to change are the Plugin ID and the name of the plugin.</td>
</tr>
</tbody>
</table>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/70814</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70814</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 01 Mar 2023 10:42:50 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog Menu on Tue, 28 Feb 2023 16:07:24 GMT]]></title><description><![CDATA[<p dir="auto"><strong>EDIT</strong>:<br />
Sorry this was not what I thought I have a dual Dialog example somewhere but not at hand ...</p>
<p dir="auto">*This is an Subdialog Example from the SDK.</p>
<p dir="auto"><a href="https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/03_application_development/gui/dialog/gedialog_subdialog_r19.py" target="_blank" rel="noopener noreferrer nofollow ugc">Github Subdialog</a></p>
<p dir="auto">hope that is in line what you are searching.*<br />
Cheers mogh</p>
]]></description><link>http://developers.maxon.net/forum/post/70804</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/70804</guid><dc:creator><![CDATA[mogh]]></dc:creator><pubDate>Tue, 28 Feb 2023 16:07:24 GMT</pubDate></item></channel></rss>