Object Plugin GUI with locked elements.
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.
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! :)
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() data.SetFloat(c4d.TESTPLUGIN_VALUE, 200.0) #2 method node[c4d.TESTPLUGIN_VALUE] = 210.0 return True
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'
- import c4d
- from c4d import plugins
- import os
- TESTPLUGIN_ID = 1000001 #Temporary ID
- TESTPLUGIN_VALUE = 10000 #Real Slider
- TESTPLUGIN_BOOL = 10001 #On/Off Checkbox
- class Testplugin(c4d.plugins.ObjectData) :
- def Init(self, node) :
- self.InitAttr(node, float, [c4d.TESTPLUGIN_VALUE])
- node[c4d.TESTPLUGIN_VALUE] = 0.0
- self.InitAttr(node, bool, [c4d.TESTPLUGIN_BOOL])
- node[c4d.TESTPLUGIN_BOOL] = True
- return True
- def GetVirtualObjects(self, op, hh) :
- obj = c4d.BaseObject(c4d.Ocube)
- obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = op[TESTPLUGIN_BOOL]
- return obj
- if __name__ == "__main__":
- bmp = c4d.bitmaps.BaseBitmap()
- dir, file = os.path.split(__file__)
- fn = os.path.join(dir, "res", "icon.tif")
- result = plugins.RegisterObjectPlugin(id = TESTPLUGIN_ID,
- str = "Test Plugin",
- g = Testplugin,
- description = "Otestplugin",
- info = c4d.OBJECT_GENERATOR | c4d.OBJECT_POLYGONOBJECT,
- icon = bmp)
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 return 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: return False return True
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.