On 03/12/2017 at 07:04, xxxxxxxx wrote:
I'm trying to create UI for my plugin that will look like Spline object UI.
As you can see in this screenshot, some settings of spline object are 'locked'. I copied the code from one of the spline objects from description folder but as you can see, my settings look completely different.
This is how my code looks like
INCLUDE ospline ; generates this ui but no settings are locked.
I wonder how this can be done in my python object plugin.
Download plugin: http://www.dropbox.com/s/rigs3rbmxeyuzps/Test Plugin 0.1.rar?dl=0
On 03/12/2017 at 10:25, xxxxxxxx wrote:
Didn't test, since I don't have a lot of time right now but should have more tomorrow.
According Python GetDEnabling is look like to be te part to override. Moreover you can find in the C++ manual of GetDEnabling an exemple about how to use it.
Hope it's help.
On 03/12/2017 at 11:05, xxxxxxxx wrote:
wow. thank you very much for the quick answer and also thanks for these links. I'll try to find answers there :)
I have another GUI related question.
I've never created plugins before, so I still can't understand how to link GUI elements and python code.
Here is a simple plugin that creates a cube object and allows moving it on a Y-axis.
I'm getting this error when adding this plugin object to my scene and this error keeps generating unless I change any parameter in the object tab.
Traceback (most recent call last) :
** File "'test plugin.pyp'", line 26, in GetVirtualObjects**
TypeError: a float is required
thank you again! :)
https://www.dropbox.com/s/ph7lv6r6iilnfox/Test Plugin 0.rar?dl=0
On 03/12/2017 at 12:39, xxxxxxxx wrote:
You have to initialize value the first time for that simply do
def Init(self, node) :
self.InitAttr(node, float, [c4d.TESTPLUGIN_VALUE])
# 1 method
data = node.GetDataInstance()
node[c4d.TESTPLUGIN_VALUE] = 210.0
You can find relevant informations and example about object creation inside ObjectData page.
Btw there is a small error in the python example of NodeData.InitAttr where op should be remplaced with node.
On 03/12/2017 at 13:04, xxxxxxxx wrote:
OMG! Thanks, buddy. U saved me again. I appreciate.
Have a nice day!
On 03/12/2017 at 16:46, xxxxxxxx wrote:
The problem with float and int values is solved but I'm getting the same problem when trying to initialize bool data type.
TypeError: __setitem__ expected int or bool, not None
after manually enabling bool checkbox, this error disappears but then I'm getting this new error:
AttributeError: 'module' object has no attribute 'TESTPLUGIN_BOOL'
Am I doing something wrong? :D
And I still can't figure out this GetDEnabling example from C++
On 04/12/2017 at 01:19, xxxxxxxx wrote:
I just notice you are using c4d constant and not directly your ID.
Then if you want to still use c4d.TESTPLUGIN_VALUE instead of TESTPLUGIN_VALUE (which is define in your script), you have to move all your constant from "res\description\Otestplugin.h" to "res\.c4d_symbols.h"
Or you can simply adapt your code
def Init(self, node) :
self.InitAttr(node, float, [TESTPLUGIN_VALUE])
self.InitAttr(node, bool, [TESTPLUGIN_BOOL])
node[TESTPLUGIN_VALUE] = 0.0
node[TESTPLUGIN_BOOL] = True
About GetDEnabling you fail it probably for the same reason
def GetDEnabling(self, node, id, t_data, flags, itemdesc) :
if id.id == TESTPLUGIN_VALUE:
Hope it's help ! :)
On 04/12/2017 at 04:58, xxxxxxxx wrote:
gr4ph0s already pointed one important issue out.
A few additions from our side:
If gr4ph0s post doesn't solve the issue completely, you may have run into another issue. Cinema 4D builds a cache of symbols (basically names for IDs, flags,...), which is stored in Cinema 4D's prefs folder (open C4D, open Preferences and click the "Open Preferences Folder..." button on the bottom left, in the appearing folder enter the prefs folder). Somettimes, when changing resource files, C4D fails to keep track of these changes. The simply delete the symbolcache file in the above described folder and restart Cinema.
If you still have any issues with GetDEnabling(), maybe you want to check out the Py-DoubleCircle example in our GitHub repository (well, of course also included in the Python SDK archive).
A final recommendation: When you post error messages and code, it can be a good idea to post the line number, where the error happened. You can get this information from the Console usually.