Basic plugin creation
-
On 16/02/2013 at 04:04, xxxxxxxx wrote:
What a pity, I wanted to do a "Repeat last Command" plugin, like Max and Maya have. Which would check with a list of chosen c4d commands to repeat them easily.
Well, another question for future plugins:
It is possible to update a plugin-gui spinner, which for instance changes a position, in realtime, without the need of an apply button? Not in an object or tag plugin.
Don´t need to know how, just if...Thanks for being such a big helper around here Niklas
-
On 16/02/2013 at 07:49, xxxxxxxx wrote:
what do you mean with Not in an object or tag plugin ? a dialog or a shader/tool ?
for dialogs, use the command/coremessage method to write/read data from/into
your dialog.for descriptions it is allso possible, but actually not the way things are
intended to be done. the message/getdenabling methods could be here a suiteable
place to implement such behaviour. for certain behaviours you would have to write a
message helper plugin to notify your plugins when they have to update themself. -
On 16/02/2013 at 08:50, xxxxxxxx wrote:
A bit confusing written, sorry. I meant the python tag or generator with user data by not in a tag....
What Im planning once my skill is good enough, is to do a much improved coordinate manager, which first of all, has an auto update, so you see the changes while adjusting.
-
On 16/02/2013 at 08:57, xxxxxxxx wrote:
So, you'll want to make a dialog. This is perfectly possible: once a value is changed by the user, you will be
notified about this change and can react on it.-N
-
On 16/02/2013 at 09:03, xxxxxxxx wrote:
ps: this feature is already implemented in c4d. the coords tab of an object node works that
way. -
On 16/02/2013 at 09:12, xxxxxxxx wrote:
Thank you, that keeps my motivation up
-
On 16/02/2013 at 09:13, xxxxxxxx wrote:
Originally posted by xxxxxxxx
ps: this feature is already implemented in c4d. the coords tab of an object node works that
way.Yeah, but just working on objects, not all the modes...
-
On 21/02/2013 at 02:31, xxxxxxxx wrote:
I´m studying this tutorial:
http://www.smart-page.net/blog/2012/02/22/smart-hn-options-cinema-4d-python-commanddata-plugin-template/
It works with some custom modules and to get a better understanding I rearanged and modified the code to be all in one single pyp file.I finally got it to work, but there a thing I still don´t understand.
This starts the function "work" when you press OK in the menu:..... result = work(aEnabledState = enableState, aSetEditor = self.GetBool(MAINDIALOG_CHECK_SETEDITOR), aSetRender = self.GetBool(MAINDIALOG_CHECK_SETRENDER), aEditor = self.GetLong(MAINDIALOG_SLIDER_EDITOR), aRender = self.GetLong(MAINDIALOG_SLIDER_RENDER), aInc = self.GetBool(MAINDIALOG_CHECK_INC))
which looks like this:
def work(aEnabledState = 0, aSetEditor = False, aSetRender = False, aEditor = 2, aRender = 3, aInc = False) doc = c4d.documents.Get...... ....... return result
It works like that, but when I put the "work" function in a class (Worker) and update the result to Worker.work:
result = Worker.work(aEnabled....
I get this message for this line:
"TypeError: unbound method work() must be called with Worker instance as first argument (got nothing instead)"
What does it mean, and what did I do wrong calling the function from the class?
Google couldn´t help me much -
On 21/02/2013 at 05:04, xxxxxxxx wrote:
Keep it the way you have it:
Make the method a staticmethod. (google)
Or make it an instance method:
1. Add the self parameter for the Worker.work() function.
2. Create an instance of the Worker class and call work() on it. -
On 22/02/2013 at 04:17, xxxxxxxx wrote:
Thanks.
I did a little Gui-Plugin, with a spinner, where the x position is read by CoreMessage and written back by Commmand. Just one thing I can´t figure out, the changes get updated in the viewport only after leaving the spinner, although the print command constantly updates:
def Command(self, id, msg) : c4d.StopAllThreads() if id == IDC_POS: obj = c4d.documents.GetActiveDocument().GetActiveObject() x_value = self.GetReal(IDC_POS) obj_pos_y = obj.GetAbsPos().y obj_pos_z = obj.GetAbsPos().z obj.SetAbsPos(c4d.Vector(x_value, obj_pos_y, obj_pos_z)) print x_value c4d.EventAdd() return True
-
On 22/02/2013 at 04:37, xxxxxxxx wrote:
- What "spinner"?
- Make your life easier:
pos = obj.GetAbsPos() pos.x = x_value obj.SetAbsPos(pos)
-Nik
-
On 22/02/2013 at 04:45, xxxxxxxx wrote:
Much easier
Spinner might be 3ds terminology, I refer to the up/down arrows next to my number edit box, which control X Position...
-
On 22/02/2013 at 06:19, xxxxxxxx wrote:
- I'm not sure what you're doing in the CoreMessage(), it shouldn't be necessary to override this method.
- You need to redraw the editor, c4d.EventAdd() just tells Cinema that something happened and a redraw will be necessary the next time Cinema would normally decide whether to redraw or not. To invoke a redraw immediately, use c4d.DrawViews().
See c4dtools.utils.update_editor() for an example call: https://github.com/NiklasRosenstein/c4dtools/blob/master/c4dtools/utils.py#L161-L163
-Nik
-
On 23/02/2013 at 02:30, xxxxxxxx wrote:
Thank you again, Core Message was just unnecessary information without real context here...
I hope I don´t become annoying, flooding beginner questionsNow I am in a dead end again:
A right-click on the arrows of a Number Box setting a specific value.
I guess it´s done by using the GeDialog.Command msg:
http://www.thirdpartyplugins.com/python_r14/modules/c4d.gui/GeDialog/index.html?highlight=command#GeDialog.Command
Or maybe withGetInputState
? Tried that too, though...But doesn´t matter what, nothing seems to work.
Best thing I achieved was to show in console, that there are some changes in the msg Container:left click:
print msg <c4d.BaseContainer object at 0x00000000188ACCA8> msg.GetDirty() 4 for x in xrange(0, 5) : print x print msg.GetIndexId(x) 0 1835362660 1 1835365985 2 1835361394 3 -1 4 -1
right click:
print msg <c4d.BaseContainer object at 0x00000000188ACCA8> msg.GetDirty() 5 for x in xrange(0, 5) : print x print msg.GetIndexId(x) 0 1835362660 1 1835365985 2 1634887027 3 1768976737 4 -1
But what now, working with some strange IDs is surely not the way to do this?
I was hoping for something like this:
def Command(self, id, msg) : if id == IDC_POS and msg.BFM_ACTION_DP_MENUCLICK == True:
which obviously, isn´t the way to go
-
On 23/02/2013 at 03:52, xxxxxxxx wrote:
It works like this, but, as I said, that´s surely not the way to do so?
if id == IDC_POS and msg.GetIndexId(2) == 1634887027:
I mean what would this msg information be good for then?
BFM_ACTION_DP_MENUCLICK bool Right mouse button. BFM_ACTION_DP_ADDSELECT bool Shift. BFM_ACTION_DP_SUBSELECT bool Control. BFM_ACTION_DP_FOCUS bool Focus. BFM_ACTION_DP_ANIMCLICK bool Animation click. BFM_ACTION_DP_BUTTONCLICK bool Double left mouse button click. BFM_ACTION_QUAL int Qualifier. _<_t_>_
-
On 25/02/2013 at 04:16, xxxxxxxx wrote:
Ok, I found a solution by GetInputState:
self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSERIGHT, msg) if id == IDC_POS and msg[c4d.BFM_INPUT_VALUE] == True:
Now I am trying to get a value offset in my dialogue:
I´ve got two Number fields an if I change the first by mouse drag, the other one should show the value offset.The thing is I don´t know how to store the inital value while mousedragging.
IDC_POS being the first field, OFFSET the second showing the offset.
Right now (base_value - x_value) keeps being zero, because the base_value gets changed while dragging too..... def Command(self, id, msg) : obj = c4d.documents.GetActiveDocument().GetActiveObject() base_value = obj.GetAbsPos().x if id == IDC_POS: if obj: x_value = self.GetReal(IDC_POS) pos = obj.GetAbsPos() self.SetReal(OFFSET, base_value - x_value, -10000000, 10000000, 1, c4d.FORMAT_METER) pos.x = x_value obj.SetAbsPos(pos) c4d.DrawViews() .......
So how can I get&store the base value, when mouse dragging starts?
-
On 25/02/2013 at 05:23, xxxxxxxx wrote:
Ok, got that too
Using "base_value = self.GetReal(IDC_POS)" as a global Variable from within CoreMessage does the job. Although I was told not to mess with global variables as a beginner, that seems like a good solution...Thanks for listening to me monologing