Sizing Plugin Dialogs

Hello,
In a previous post, How to open a GeDialog Modal to default width & height? the solution to the defaultw/defaulth bug for a script Modal was to pass the pluginid. I am trying this solution with a Command Plugin and I'm not getting the specified sizes for either window. I thought maybe it has to do with the subid but my Main Dialog isn't behaving either.

Here is some test code I'm using:

import c4d
from c4d import documents, gui, plugins

PLUGIN_ID = 1055306 #test id
ANOTHER_DLG_ID = 5000

class AnotherDlg(gui.GeDialog):
    MY_TEXT = 1000

    def CreateLayout(self):
        self.SetTitle("Another Dialogue")
        self.AddStaticText(self.MY_TEXT, c4d.BFH_CENTER | c4d.BFH_SCALE,
                           name="Another Dialog",inith=40)
        return True

class MyDlg(gui.GeDialog):
    MY_BUTTON = 1000
    def __init__(self):
        global anotherDialog
        self.anotherDialog = AnotherDlg()

    def CreateLayout(self):
        self.SetTitle("Test")
        self.AddButton(self.MY_BUTTON, c4d.BFH_CENTER | c4d.BFH_SCALE | c4d.BFV_CENTER | c4d.BFV_SCALE, initw=0, inith=0, name="Open Dialog")
        return True

    def Command(self, id, msg):
        if id == self.MY_BUTTON:
            self.anotherDialog.Open(c4d.DLG_TYPE_MODAL, pluginid=PLUGIN_ID, subid=ANOTHER_DLG_ID, xpos=-2, ypos=-2, defaultw=600, defaulth=150)
        return True

    def Restore(self, pluginid, secref):
        if secref['subid'] == ANOTHER_DLG_ID:
            return self.anotherDialog.Restore(pluginid, secref)
        else:
            return super(MyDlg, self).Restore(pluginid, secref)

class MyData(c4d.plugins.CommandData):
    dialog = None

    def Execute(self, doc):
        if self.dialog is None:
            self.dialog = MyDlg()
            global myDlg
            myDlg = self.dialog
        return myDlg.Open(dlgtype=c4d.DLG_TYPE_ASYNC, xpos=-2, ypos=-2,
            pluginid=PLUGIN_ID, defaultw=700, defaulth=300)

    def RestoreLayout(self, sec_ref):
        if self.dialog is None:
            self.dialog = MyDlg()
            global myDlg
            myDlg = self.dialog
        return myDlg.Restore(pluginid=PLUGIN_ID, secref=sec_ref)

if __name__ == "__main__":
    plugins.RegisterCommandPlugin(id=PLUGIN_ID,
                                str="Test",
                                info=0,
                                help="Test",
                                dat=MyData(),
                                icon=None)

Here are the results:
Annotation 2020-06-23 144536.png

The Main Dialog (DLG_TYPE_ASYNC) is 324x51 and the secondary dialog (DLG_TYPE_MODAL) is 324x100. This is making layout difficult.

Can anyone please help me to get these to open to the specified sizes? Thank you!

UPDATE:
I'm thinking that the Main Dialog cannot be resized as it is DLG_TYPE_ASYNC. The secondary Dialog is taking the width from the last dragged dimensions of the Main Dialog.

I'm not sure if this is correct, but I was able to get the dimensions I needed for the secondary GeDialog by giving it a unique PLUGIN_ID and removing the subid (code below).

self.anotherDialog.Open(c4d.DLG_TYPE_MODAL, pluginid=ANOTHER_DLG_ID, xpos=-2, ypos=-2, defaultw=600, defaulth=450)

Do I need to create a unique PLUGIN_ID for every GeDialog or is there another way?

Hi @blastframe thanks for writing us.

Yes, as stated in your second post having unique ids for the different dialog is the safer way to prevent unexpected behavior like the one reported initially. Tested successfully (both main (async) dialog and modal dialog were correctly sized and placed on mac and windows) I also confirm there's no need to specify the subid.
PC_12691.png

Best, R

Hi @r_gigante, thank you for the reply!

With regards to the DLG_TYPE_ASYNC, the GeDialog size has not always worked consistently for me. Is Cinema 4D storing information for when the Async GeDialogs have been resized? If so, is there a way to clear this preference? Thanks!

Hi @blastframe, I apologize for having left this thread unanswered for such a long time and I hope it still meaningful to you getting answered.

I confirm that Cinema 4D indeed stores such information, but the BaseContainers used are not accessible from the outside and you can't modify their data.

Can you provide us an example to reproduce the lack of consistency you mentioned?

Cheers, R

Hi,

without further feedback, we will consider this thread as solved by Wednesday and flag it accordingly.

Cheers,
Ferdinand

Hi team, thanks for the replies. Like you I'm sure, I've been very busy since the initial topic was created six months ago and don't have any examples on hand. I'll keep my eyes open for them in future projects though and post if I can reproduce. Thanks.

Hi @blastframe,

this was not request for you to get work, but simply part of our support management. People often forget that they have posted a "Ask-as-question"-topic and we have to deal with these cases somehow. I interpret your answer in that way, that you still have questions, but hadn't time yet to tackle them, right? Then I will leave this question open for now.

Cheers,
Ferdinand

Hi @blastframe,

without further questions or feedback, by Monday we will consider this thread as solved and flag it accordingly.

Cheers,
Ferdinand