c4d.plugins.ObjectData
¶
An object plugin class. Register this class with
RegisterObjectData()
.
Note
Before starting to develop a
ObjectData
plugin, read
NodeData Management
before.
See also
Py-DoubleCircle , Py-Gravitation , Py-RoundedTube and Py-SpherifyModifier plugin examples.
On each call of a method of your class (Python), Python has to manage a lot of stuff so that the method can be called. The method
ObjectData.GetVirtualObjects()
is called on each frame and if you do not want to calculate the object on each frame again and again you can still return the cache object with the following code:
def GetVirtualObjects(self, op, hh): dirty = op.CheckCache(hh) or op.IsDirty(c4d.DIRTY_DATA) if dirty is False: return op.GetCache(hh)
This is the common way how to return the cache object so Python do not has to built the whole object on each frame. That saves a lot of time. But how you can read some lines before, just calling the method needs some time, because Python has to register this call to the internal management system.
So there is a second way how to return the cache of your already-built object on a level which is much closer to the internal system than Python. You can set a flag in your class which is checked after the constructor of your object was read. The code you see above is called and if there is a cache available the Python method is not called anymore because the cache is already taken. That saves a lot of time. To use this code you should take a look at the following class:
class CacheTest(plugins.ObjectData): """CacheTest Generator""" def __init__(self): self.SetOptimizeCache(True) def GetVirtualObjects(self, op, hh): # Disabled the following lines because cache flag was set so the cache build is done before this method is called #dirty = op.CheckCache(hh) or op.IsDirty(c4d.DIRTY_DATA) #if dirty is False: return op.GetCache(hh) # Create cube return c4d.BaseObject(c4d.Ocube)
c4d.plugins.
ObjectData
¶
ObjectData.GetDimension()
ObjectData.Draw()
ObjectData.DrawShadow()
ObjectData.DetectHandle()
ObjectData.MoveHandle()
ObjectData.AddToExecution()
ObjectData.Execute()
c4d.plugins.NodeData
ObjectData.
GetDimension
(
self
,
op
,
mp
,
rad
)
¶
Override - Return the boundaries of your object.:
def GetDimension(self, op, mp, rad): """ (i) When the method runs without a raised exception mp and rad will be internally copied, otherwise they are ignored. """ mp.x = self.x_size # correct mp.y = self.y_size # correct mp.z = self.z_size # correct mp = c4d.Vector(x_size, y_size, z_size) #!!! wrong !!! do not rebind mp! #this assign applies for 'rad' as well return
Parameters: |
|
---|
ObjectData.
Draw
(
self
,
op
,
drawpass
,
bd
,
bh
)
¶
Override - Called when the display is updated for you to display some visual element of your op in the 3D view.
Note
This function is called in a thread context. Please see the important information about threading.
Parameters: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
int |
||||||||||
Returns: |
Success of drawing into the editor view:
|
ObjectData.
DrawShadow
(
self
,
op
,
bd
,
bh
)
¶
New in version R14.014.
Called during the shadow pass instead of the
Draw()
method.
Parameters: |
|
||||||
---|---|---|---|---|---|---|---|
Return type: |
int |
||||||
Returns: |
Success of drawing into the editor view:
|
ObjectData.
GetVirtualObjects
(
self
,
op
,
hh
)
¶
Override - Return an object chain of a generator object (e.g. a polygonal object).
Note
This function is called in a thread context. Please see the important information about threading.
Note
Please read the Optimize Cache section at the top of this page to get in touch with the caching options.
Warning
Must not be overridden for non-generator objects.
Parameters: |
|
---|---|
Return type: | |
Returns: |
The newly allocated object chain, or None if a memory error occured. |
Note
Only return None in the case of a memory error. If the generator does not produce any output (e.g. when the user chooses wrong settings) it must at least return an (empty) Onull object, otherwise Cinema 4D will try to rebuild the cache again and again.
ObjectData.
GetContour
(
self
,
op
,
doc
,
lod
,
bt
)
¶
Override - Return a spline contour. For spline objects only.
Note
This function is called in a thread context. Please see the important information about threading.
Note
Splines created through
GetContour()
are cached. To make this frame dependent,
CheckDirty()
can be overloaded to set the object dirty if a certain condition has changed.
Warning
Must not be overridden for non-spline objects.
Parameters: |
|
---|---|
Return type: |
c4d.SplineObject or None |
Returns: |
The newly allocated spline or None |
ObjectData.
ModifyObject
(
self
,
mod
,
doc
,
op
,
op_mg
,
mod_mg
,
lod
,
flags
,
thread
)
¶
Override - Called when an object plugin should modify the passed object.
Note
This function is called in a thread context. Please see the important information about threading.
Warning
Must not be overridden for non-modifier objects.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
Success of modifying the object. |
ObjectData.
CheckDirty
(
self
,
op
,
doc
)
¶
Override - You can override this function to check for a change in the object manually. This example will make your object update every frame:
def CheckDirty(self, op, doc): frame = doc.GetTime().GetFrame(doc.GetFps()) if frame != lastFrame: lastFrame = frame op.SetDirty(c4d.DIRTYFLAGS_DATA)
This method is useful to override in deformer and spline plugins.
Note
This function is called in a thread context. Please see the important information about threading.
Parameters: |
|
---|
ObjectData.
MoveHandle
(
self
,
op
,
undo
,
mouse_pos
,
hit_id
,
qualifier
,
bd
)
¶
Override - Move a handle manually.
Parameters: |
|
||||||
---|---|---|---|---|---|---|---|
Return type: |
bool |
||||||
Returns: |
Success of modifying the handle. |
ObjectData.
DetectHandle
(
self
,
op
,
bd
,
x
,
y
,
qualifier
)
¶
Override - Manually detect a click on a handle.
Parameters: |
|
||||||
---|---|---|---|---|---|---|---|
Return type: |
int |
||||||
Returns: |
The handle ID that is to be passed to
|
ObjectData.
AddToExecution
(
self
,
op
,
list
)
¶
Override - By default this function returns
False
. Then Cinema 4D will call
Execute()
at the priority specified by the user in the
EXPRESSION_PRIORITY
parameter of the container.
If you override this function and return True , then you can insert your own points of execution in the list by calling for example:
list.Add(op, c4d.EXECUTIONPRIORITY_ANIMATION, 0) list.Add(op, c4d.EXECUTIONPRIORITY_GENERATOR, 0)
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True if you override this function and has added stuff to list. |
ObjectData.
Execute
(
self
,
op
,
doc
,
bt
,
priority
,
flags
)
¶
Override - Called at the point in the priority pipeline specified by
AddToExecution()
, or the lack thereof.
Note
This function is called in a thread context. Please see the important information about threading.
Parameters: |
|
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
int |
||||||||||||||||||||||||||||
Returns: |
The result:
|
ObjectData.
ModifyParticles
(
self
,
op
,
pp
,
ss
,
pcnt
,
diff
)
¶
Override - Called for modifying particles. This is for particle modifiers only.
Note
This function is called in a thread context. Please see the important information about threading.
Parameters: |
|
---|
ObjectData.
GetHandleCount
(
self
,
op
)
¶
New in version R18.011.
Called to get the number of handles the object has. Part of the automated handle interface.
Parameters: | op ( c4d.BaseObject ) – The established base object. |
---|---|
Return type: | int |
Returns: | The number of handles for the object. |
ObjectData.
GetHandle
(
self
,
op
,
i
,
info
)
¶
New in version R18.011.
Called to get the information for handle at index i . Part of the automated handle interface.
Parameters: |
|
---|
ObjectData.
SetHandle
(
self
,
op
,
i
,
p
,
info
)
¶
New in version R18.011.
Called to set the information for handle at index i . Part of the automated handle interface. Called when the user has moved handle i to position p . Update the object’s internal data accordingly (e.g. parameter values etc).Parameters: |
|
---|