Dialogue Box/Manager through Plug-in vs Vanilla Script?
-
Hi,
Is there a difference if I create a floating UI from a Plug-in vs Vanilla Script?
I'm planning to create a floating UI manager where it lists all my scripts for easy access. They are just utility scripts but they are increasing and I would like to categorize them through a floating UI manager for handling
A sample of Dialogue Box vanilla script would be something like this Simple Object Renamer
A sample of Dialogue Box through plug-in would be something like this Python Dialog Tutorial
So far, what I understand in Dialogue Box through Vanilla Script is
You can't access anything when you open a dialogue box through a vanilla script. This makes it a no-go for this particular project where I require a floating UI and still be able to access objects in the scene. Correct me if I'm wrong
Dialogue Box through plug-in seems like a good way to go. The only thing annoying about it is since it is in .pyp the IDE does not recognize the syntax. So I keep renaming it every now and then to .py and back to .pyp. Restart C4D for it to take effect. Other than that. I'm not sure if there are any gotchas compared to the vanilla script.
Basically, I just need a clarification on my understanding above. Sorry for the basic question but coming from Maya almost all dialog box is written as script and not as a plug-in.
Thank you for looking at my problem.
-
The sample "Simple Object Renamer" uses a DLG_TYPE_MODAL for its dialog, which means the dialog is open and waiting for input from the user pressing OK or Cancel in order to proceed.
Replacing it with DLG_TYPE_ASYNC then allows to still access anything while the dialog is open.A plugin usually uses an asynchronous dialog, while a script, since usually a "single shot" action, will need a modal dialog, waiting for input before proceeding.
-
Thanks for the heads-up on
DLG_TYPE_ASYNC
. It modifies the behavior but it does change the layout unexpectedly. I guess this is for another topic.Just for clarification:
- There is no functional difference between calling up a dialogue box from a script and plug-in since they are using the same command anyway
- Is there a solution for an IDE not recognizing .pyp as python syntax? (I know not directly related to C4D API but just taking chances here)
Thank you for looking at the problem.
-
Hi @bentraje, as you already figured DLG_TYPE_MODAL stop the execution of Cinema 4D and any interaction with any others component than your Modal Dialog is not possible. This is a limitation due to the scope of the script since a script is executed at one time, the dialog can't be stored in the memory and will lead to weird behavior.
So DLG_TYPE_ASYNC are only possible on plugin since you can create a CommandData plugin that will hold the reference of your dialog all the time. (So you are sure the Python Garbage Collector, did not erase the dialog).
You can find an example in the Py-CVRss example.
Regarding your second question, I'm sure with a little search on google with "Add FileType IDE", will find you good results. Since any decent IDE allows you to add custom extensions for any language you want.
If you have more question, please let me know.
Cheers,
Maxime. -
Thanks for further clarification specially the catch with the dialog's on the script. Will now closed the thread.
Have a great day ahead!