On 13/02/2018 at 11:47, xxxxxxxx wrote:
(Object Generator Plugin in Python for Cinema 4D R19.024 on macOS Sierra)
I'm not able to delete points (in point mode) of a custom point object generator.
It will result in the following error:
Modeling Kernel Error : Invalid Object
Modeling Kernel Error : Failed
See the code below for a simplified example.
Point handles will not be drawn in the example code. Move the mouse pointer over the beginning or the end of the line, to select a point when in point mode.
PS: I'm new to Cinema 4D plugin development and new to Cinema 4D in general.
from c4d import bitmaps, gui, plugins, utils
PLUGIN_ID = 9199191
class TestPlugin(plugins.ObjectData) :
def Init(self, node) :
node.SetPoint(0, c4d.Vector( 0.0, 0.0, 0.0))
node.SetPoint(1, c4d.Vector(100.0, 0.0, -100.0))
node.SetPoint(2, c4d.Vector(200.0, 0.0, 100.0))
node.SetPoint(3, c4d.Vector(300.0, 0.0, -100.0))
def GetVirtualObjects(self, op, hierarchyhelp) :
dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)
if dirty is False: return op.GetCache(hierarchyhelp)
splineObj = c4d.SplineObject(op.GetPointCount(), c4d.SPLINETYPE_LINEAR)
if __name__ == "__main__":
path, file = os.path.split(__file__)
bmp = bitmaps.BaseBitmap()
bmp.InitWith(os.path.join(path, "res", "some.tif"))
id = PLUGIN_ID,
str = "Py-TestPlugin",
g = TestPlugin,
description = "Opytestplugin",
icon = bmp,
info = c4d.OBJECT_GENERATOR | c4d.OBJECT_POINTOBJECT )
On 14/02/2018 at 04:39, xxxxxxxx wrote:
it looks like you wan to generate a spline. Similar to your other thread (Polygons disappear with Polygon Object Generator), you don't need to set the OBJECT_POINTOBJECT flag on registration.
Instead you need to set the OBJECT_ISSPLINE flag on registration. And then you don't override GetVirtualObjects() but instead GetContour(). I suggest to take a look at the Py-DoubleCircle example.
On 14/02/2018 at 05:11, xxxxxxxx wrote:
I don't want to generate a spline object. The code above is a simplified example for the problem and I generate the spline only for visualization. The actual plugin I'm working on is a more complex point object generator and when I delete points in point mode I get the error mentioned above.
On 21/02/2018 at 09:18, xxxxxxxx wrote:
sorry, for the long time to answer here.
I can reproduce the error message, but unfortunately have to say, it is an undefined use-case. By the way, you can produce the same error by trying to delete points from our FFD deformer.
This is the result of some internal changes in the recent past. An issue got created in our bug tracker. But please be aware, this is no functional issue (at least not as far as I can see), but only an erroneously thrown error message in the Console.
Now, for your actual issue (deleting points) : I'm afraid, it's simply not the way a generator is designed in C4D. At least I am not aware of any generator, allowing the deletion of (control-)points. I think something like this is usually achieved with a generator (generating your complex point object) with an input point (or rather polygon) object.
On 26/02/2018 at 03:11, xxxxxxxx wrote:
Thanks for your help Andreas!
I solved the problem with a workaround / hack by listening to delete key press events and then deleting the points in my own function.