Blah! Bummer. Seemed like a bug to me. I guess I will just convert this to a CommandData plugin and use GeDialog.
Posts made by BretBays
-
RE: ToolData Linkbox does not retain object when one is dragged in.
-
RE: How to Undo Switching Between Modes?
@ferdinand said in How to Undo Switching Between Modes?:
Well, just move the code which switches the mode to the end of your code when it is only cosmetic anyways. As I said above, a sensible way to use
SetMode
is when you want to leave the user in a state where he or she can continue working right away. But you can then just run all your code, check if everything went fine and then set your code. Otherwise you never set the mode, and therefore also have nothing to revert.It's a matter of workflow. It's not simply for checking the code that it's working properly. It's about a workflow. The workflow in the example is Select some mesh components, run the command. It generates something for you and switches the mode for you. If you selected the wrong components, you'd undo and try it again. But the undo won't put you back in the component mode. The issue is that that part of the command is not undoable so it's does hinder the workflow just a bit. I'm not necessarily advocating that it should be undoable or anything like that, just explaining the reasoning in this example and the value if it were undoable.
-
RE: ToolData Linkbox does not retain object when one is dragged in.
I would do that, except the process for creating a plugin is not trivial and in no way intuitive anymore. There's no resEdit to generate all the necessary resource information and UI elements, so now I have to do that manually. That means to provide a meaningful and functional example, I need to now go through the several hoops of creating a plugin just for this test, despite giving reasonably clear indications of what is being done function and plugin-wise. And despite going through the process of getting a new plugin ID, and creating a new folder, .pyp file, res, strings_us, renaming my classes, using the correct, new, throwaway plugin ID, my plugin wont even initialize. Even though it's the same code as my actual plugin, just with renamed classes and file, and stripped down, the plugin would not initialize. So here's the code that had to hijack an existing toolData plugin SDK example to demonstrate the issue.
""" Copyright: MAXON Computer GmbH Author: XXX, Maxime Adam Description: - Tool, Creates a liquid Painter Tool. - Consists of Metaball and Sphere. Class/method highlighted: - c4d.plugins.ToolData - ToolData.GetState() - ToolData.MouseInput() - ToolData.Draw() - ToolData.GetCursorInfo() - ToolData.AllocSubDialog() """ import c4d import os # Be sure to use a unique ID obtained from www.plugincafe.com PLUGIN_ID = 1025247 # Values must match with the header file, usd by c4d.plugins.GeLoadString IDS_PRIMITIVETOOL = 50000 class SettingsDialog(c4d.gui.SubDialog): """Creates a Dialog to show the ToolData options. This dialog will be displayed in the Attribute Manager so this means the ToolDemoDialog will be instantiate each time the tool is activate and destruct when the AM change its mode. """ def __init__(self, sharedDict): super(SettingsDialog, self).__init__() def CreateLayout(self): self.SetTitle("BB-Distribute Points") self.GroupBegin(id=100010, flags=c4d.BFH_SCALEFIT, cols=1, rows=5, title="BB-Distribute Points") self.GroupBegin(id=200010, flags=c4d.BFH_SCALEFIT, cols=2, rows=1) #bc=c4d.BaseContainer() self.AddCheckbox(id=8888, flags = c4d.BFH_LEFT, initw=10, inith= 10, name="") self.linkGadget = self.AddCustomGui(9898, c4d.CUSTOMGUI_LINKBOX, "Custom", c4d.BFH_SCALEFIT, minw=100, minh=10) self.GroupEnd() self.GroupEnd() return True def Command(self, commandID, msg): """This Method is called automatically when the user clicks on a gadget and/or changes its value this function will be called. It is also called when a string menu item is selected. Args: commandID (int): The ID of the gadget that triggered the event. msg (c4d.BaseContainer): The original message container Returns: bool: False if there was an error, otherwise True. """ if commandID == 9898: print(self.linkGadget.GetLink()) class LiquidTool(c4d.plugins.ToolData): """Inherit from ToolData to create your own tool""" def __init__(self): self.data = {'sphere_size':15} def AllocSubDialog(self, bc): """Called by Cinema 4D To allocate the Tool Dialog Option. Args: bc (c4d.BaseContainer): Currently not used. Returns: The allocated sub dialog. """ return SettingsDialog(getattr(self, "data", {'sphere_size': 15})) if __name__ == "__main__": # Retrieves the icon path directory, _ = os.path.split(__file__) fn = os.path.join(directory, "res", "liquid.tif") # Creates a BaseBitmap bmp = c4d.bitmaps.BaseBitmap() if bmp is None: raise MemoryError("Failed to create a BaseBitmap.") # Init the BaseBitmap with the icon if bmp.InitWith(fn)[0] != c4d.IMAGERESULT_OK: raise MemoryError("Failed to initialize the BaseBitmap.") # Registers the tool plugin c4d.plugins.RegisterToolPlugin(id=PLUGIN_ID, str="Py-Liquid PainterBB", info=0, icon=bmp, help="This string is shown in the statusbar", dat=LiquidTool())
This is a copy of an SDK example of a toolData plugin, it does the same thing I am doing in my plugin which is using and was as I described in my first post
def AllocSubDialog(self, bc)
in the toolData pluginto call ac4d.gui.SubDialog
class that is callingCreateLayout(self)
which inside there is usingself.linkGadget = self.AddCustomGui(9898, c4d.CUSTOMGUI_LINKBOX, "Custom", c4d.BFH_SCALEFIT, minw=100, minh=10)
. I also added the Command bit from your example, and it will print the object, but the object does not get retained.Open Cinema. Select Py-Liquid PainterBB. Drag any object into the link field of the AM and it should disappear immediately.
-
RE: How to Undo Switching Between Modes?
I think the idea is that when working with this and testing it, it becomes a thing that the user has to manage themselves.
Imagine you have a script that takes point selections, then creates a null, and then switches to object mode with the null selected so you can immediate move the null.
You hit undo, null is gone. Back to your point object selected, but you are still in model mode. So to run it again youd need to manually switch back to point mode, THEN run the script again.
Thats what I think the idea for the use case is.
-
RE: ToolData Linkbox does not retain object when one is dragged in.
Does it still work if you instead put it into a SubDialog and call that subDialog from a tooldata plugin? Because thats the only thing I can see from my code. As ive mentioned, I have used linkboxes successfully before, but it was always in CommandData plugins with GeDialog not ToolData plugins with SubDialog so it shows up in the Attribute Manager vs a pop up window. I wasn't sure if there is some sort of difference I need to account for there.
-
ToolData Linkbox does not retain object when one is dragged in.
Howdy,
I found myself with some time to look at my plugin I was working on. It is a ToolData plugin that usesAllocSubDialog
to call my subDialogClass. In my subDialog class, I am using createLayout to make a linkbox customGUI element via the following line in my CreateLayout functionself.linkGadget = self.AddCustomGui(9898, c4d.CUSTOMGUI_LINKBOX, "Custom", c4d.BFH_SCALEFIT, minw=100, minh=10)
In terms of drawing my UI, it all works. I see my link box no problemo. I began to try to do some GetLinkObject type functions to query the field and return it's value. That seems to be working, however I can't fully test it because I cannot seem to actually drag and drop my opject into the link field and have it stick.
I feel like this is something pertaining to the messaging and stuff of a toolData plugin? I have used link fields many times in CommandData plugins, but this is my first toolData plugin. Is there something special I need to do in order to make it stick?
-
Tool Tabs and foldable groups
I am working on a ToolData plugin , and it's going well enough at the moment. But I see various UI elements that I cannot seem to find any documentation on how to achieve. The best example I can give is the Extrude Tool(although there are many tools that work in this way).
How do you create the tabs like in the extrude tool where you can select 1 or multiple tabs and display all the UI elements? The tabGroupBegin was where I thought but it seems to be strictly tabs, radios, or drop down.
The other thing that is interesting is the foldable sections. Is that using BFV_BORDERGROUP_FOLD or is that something much more complex?
-
Question about organizing and utilizing custom python plugin libraries
That title might be a bit confusing. Allow me to try and explain.
I have some ideas for a few different commandData plugins. The plugins pertain to extracting Joint Weight Data from certain deformers. For example extracting a skinned ffd deformer into joint weights. Extracting the effects of a delta mush deformer into joint weights, extracting a spline deformer to joint weights, etc.
My thought is to make X number of different commandData plugins for each instance, however all of these plugins use a lot of shared functions that I have written to do sort of generalized steps of each of these(Get the weight tag from an object, Creating weight maps from something, etc). So my question is how do I organize this in such a way so that I can have my shared libraries separate that each command data plugin could access without each plugin needing all the duplicate functions in there? I hope that makes some sense.
It's kind of like being able to do:
import myLib myLib.myFunction()
But I am not sure how to manage that across multiple plugins that will be source protected, and how to go about distributing that.
I hope this make some sort of sense.
-
RE: Foldable Groups in Python GeDialog
Interesting. Thank you for that.
So then, that makes me want to ask, in the case of the foldable Transform and Freeze Transform groups in the coordinates tab of an object, would that mean those are like a bitmap button inside of a group is the parent of another group that is just being hidden?
-
RE: Capture the dragging and release of a marker via python
Follow up but slightly unrelated question. If I have a GeDialog plugin with an edit field(for changing the Frame of a marker for example), is it possible to have it update while dragging vs on release? Is that some sort of CoreMessage thing? Right now I have a call inside of my Command function that basically says if the ID matches the edit field then set the marker frame. But I would like to be able to click and drag and see the marker's position move as I drag. Is that possible
-
RE: Foldable Groups in Python GeDialog
For some context, I wrote this plugin many many moons ago, and would like to modernize it a bit, and be able to collapse some of the groups so the whole plugin is not overwhelming https://vimeo.com/manage/videos/83452164
-
RE: Capture the dragging and release of a marker via python
Hey Ferdinand,
Thank you for your detailed response. It sounds like it may be a bit overkill for what I was thinking, and thats ok. I will read over it more and evaluate from there.
-
Capture the dragging and release of a marker via python
I have an idea, where I want something to happen when I click and drag on a marker in the timeline, but I am not sure where to begin with getting that sort of event trigger, or if it is even possible in Python.
Simplest example would be to print the new frame number of the marker's location once I release it.
Would I need to like, enter a tool/context in order to track that?
For more context, I wrote a script that Based on whatever marker I had selected(if the key was within the length of the marker), and I thought it might be cool to be able to shift those keys when I moved the marker as well, but I got a bit lost.
-
Foldable Groups in Python GeDialog
I feel like I have maybe asked this before, but I couldn't find an answer for python for this.
Is it possible to create foldable groups in a GeDialog? Kind of like what you see in Attribute Settings. I basically just want to be able to make foldable sections in my GeDialog and was struggling to see how to achieve that as the flags didn't seem to be working.
-
RE: How to create python plugin in 2024?
@ThomasB said in How to create python plugin in 2024?:
Yes, download the SDK and study the examples.
I wrote my own software that allows me to simply select the type of plugin I want to create, enter the plugin ID and the plugin name. The program then creates the folder structure, all files with the correct content and the correct name automatically...that was the first thing I did because it is always extremely tedious.
This then takes 10 seconds and I have a finished blueprint. Then I can start programming straight away.
I usually make the Gui first using UserData to roughly create the design and then I write it down in the resfile in no time at all. It's relatively quick and even fun and you gradually grow into it, it emerges little by little.....Basically it wouldn't be a problem to write a script that writes the UserData interface into a Res, header and string file, I already have an idea for that... That would actually be easy to do.
I'll get to it when I'm done with my update... and then maybe make it available to the community... However, a similar one is already there, but I can't remember where.Greetings
TomYeah, that sounds cool. The ui stuff you're mentioning was very similar to how the old ResEdit plugin worked. the source code is on gitHub, but I don't know how to compile C++ plugins.
But I guess there is nothing there. This stems from me copying one of the examples from the Python SDK and trying to make it my own. It hasn't been very intuitive for me, which is why I asked because I figured I must have been missing something, but it seems I am not.
-
RE: How to create python plugin in 2024?
That is sort of what prompted the question. I'm developing a toolData plugin, and was looking at an example, but that leads to renaming classes in the code and such, but there doesn't seem to be any tool or anything ensure that the res files get renamed properly. ResEdit was very nice because in addition to helping visualize the gui elements, it managed the generation of those res files for you.
-
How to create python plugin in 2024?
Howdy,
I feel kinda dumb asking this, but since there doesn't seem to be a working version of ResEdit, I fear I no longer recall the correct ways to set up and create a proper python plugin now? Like how does the c4d_symbols.h get created? The descriptions and all of that now without resEdit? Is there a link or tutorial for getting started. How does one generate the proper resource files, not just for ui elements, but just the normal c4d_symbols.h, or any other resource file?
-
Python Weight Painting Brush Plugin Questions
Howdy,
I have some scripts that manipulate joint weighting, and one of them I would like to maybe push myself towards trying to make it a brush type plugin...thing. Unfortunately, I don't really know where to begin with that so I have some questions for getting started.
-
What plugin type should this be? Would it be a SculptBrushToolData or no since it wouldn't be actually affecting or manipulating the points on the mesh themselves?
-
If it shouldn't be SculptBrushToolData, then what plugin type should it be?
If anyone can point me in the right direction for where to being with some of that, it would be greatly appreciated. My idea basically just needs to get whatever verts are within the radius of the brush and then run the command, and potentially continue to run the command. So It would likely have a radius, no falloff, and then possibly a checkbox or two for some specific flags.
-
-
RE: [PYTHON] How to properly set the toggle of viewport solo
In the past I have refrained from CallCommands and CallButtons because they used to add to the undo queue or did. But I suppose in this instance I can just do it for thise purpose.
-
[PYTHON] How to properly set the toggle of viewport solo
Howdy,
I was wondering how I could go about enabling/disabling the viewport solo through python(not through CallCommand). I don't see it as a BIT or NBIT to change, but it is also not a tool or modeling command as far as I can tell. Searching the API for VIEWPORT_SOLO_MODE doesn't turn anything up. I was wanting to be able to set and toggle it and the other solo options like Hierarchy etc. Does anyone have any info on how to work with that?