On 11/10/2014 at 16:38, xxxxxxxx wrote:
Hi.
as far as I know, the Python generator don´t let you insert a converted polygonal version, offhandedly.
You can write your own Sphere object or use this workaround;
The generator has some userdata to manipulate the sphere and a child object which stays every time updated.
Like this example:
import c4d
from c4d import utils
def main() :
obj=c4d.BaseObject(c4d.Osphere)
# check if there is allready userdata for the python generator
# just to begin with something; insert userdata for the radius of the sphere
if op.GetUserDataContainer() == []:
radius=c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)
radius[c4d.DESC_NAME] = "radius"
op.AddUserData(radius)
radiusvalue = op[c4d.ID_USERDATA,1]
else:
radiusvalue = op[c4d.ID_USERDATA,1]
#set the sphere to the user given radius
obj[c4d.PRIM_SPHERE_RAD] = radiusvalue
#convert to a polygonal object
newobjList = utils.SendModelingCommand(
command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
list= [obj.GetClone()],
mode=c4d.MODELINGCOMMANDMODE_ALL,
doc = doc)
#instead of letting the generator creating an object directly
#do this set and replace code for your polygonal object
if op.GetDown()==None:
doc.InsertObject(newobjList[0],op)
else:
obj_2=op.GetDown()
obj_2.Remove()
doc.InsertObject(newobjList[0],op)
return
But I´m not sure if this is the best solution.
I´m really interested, if there is a better way to solve it.
There was another post with a circle object lately.
https://plugincafe.maxon.net/topic/8124/10584_python-generator--spline-outline
cheers
Martin
Edit:
the geometrical manipaltion of the sphere will be gone after the generator refreshes the sphere.
It´s just a replacement.
if you want real procedural geometrie watch out for the Houdini integration.
or Fabric engine at the beginning of 2015.