On 13/02/2018 at 11:00, xxxxxxxx wrote:
(Object Generator Plugin in Python for Cinema 4D R19.024 on macOS Sierra)
Hello Everyone!
If I register an object plugin as a c4d.OBJECT_GENERATOR | c4d.OBJECT_POLYGONOBJECT and return a polygon object from the GetVirtualObjects() method, the polygon object will disappear from the view, when I switch from model mode to point mode.
If the plugin will be registered as a c4d.OBJECT_GENERATOR | c4d.OBJECT_POINTOBJECT, the polygon object will NOT disappear from the view, when I switch from model mode to point mode.
Like with the point object generator, I would like to be able to see the polygon object of a polygon object generator when I switch to point mode. Is this possible?
See the code below for a simplified example.
Best regards
Tim
PS: I'm new to Cinema 4D plugin development and new to Cinema 4D in general.
import math
import sys
import os
import c4d
from c4d import bitmaps, gui, plugins, utils
PLUGIN_ID = 9119119
class TestPlugin(plugins.ObjectData) :
def Init(self, node) :
return True
def GetVirtualObjects(self, op, hierarchyhelp) :
dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)
if dirty is False: return op.GetCache(hierarchyhelp)
return self.CreateSimplePolyObj()
def CreateSimplePolyObj(self) :
op = c4d.PolygonObject(4, 1)
op.SetPoint(0, c4d.Vector( 0.0, 0.0, 0.0))
op.SetPoint(1, c4d.Vector(100.0, 0.0, 0.0))
op.SetPoint(2, c4d.Vector(100.0, 0.0, 100.0))
op.SetPoint(3, c4d.Vector( 0.0, 0.0, 100.0))
polygon = c4d.CPolygon(0, 1, 2, 3)
op.SetPolygon(0, polygon)
op.SetPhong(True, 1, utils.Rad(80.0))
op.Message(c4d.MSG_UPDATE)
return op
if __name__ == "__main__":
path, file = os.path.split(__file__)
bmp = bitmaps.BaseBitmap()
bmp.InitWith(os.path.join(path, "res", "some.tif"))
plugins.RegisterObjectPlugin(
id = PLUGIN_ID,
str = "Py-TestPlugin",
g = TestPlugin,
description = "Opytestplugin",
icon = bmp,
info = c4d.OBJECT_GENERATOR | c4d.OBJECT_POLYGONOBJECT )