This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com
Here is an example how to use:
import c4d
obj = c4d.BaseObject(c4d.Ocube)
obj.SetPos(c4d.Vector(20))
#now you can insert the object in a document
The base class of objects.
// Coordinates info
// Other stuff
//Still private
BaseList2D
PointObject CameraObject
| Parameter: | type (int) – The id of the object, e.g: (Ocube). See also: Types |
|---|---|
| Return type: | BaseObject |
| Returns: | The new base object. |
Returns the local matrix that represents the objects position, scale and rotation
| Return type: | Matrix |
|---|---|
| Returns: | The matrix. |
Set the local matrix that represents the objects position, scale and rotation.
| Parameters: |
|
|---|
Returns the global matrix that represents the objects position, scale and rotation
| Return type: | Matrix |
|---|---|
| Returns: | The matrix. |
Set the global matrix that represents the objects position, scale and rotation.
| Parameters: |
|
|---|
Returns the local normalized matrix that represents the objects position, scale and rotation
| Return type: | Matrix |
|---|---|
| Returns: | The matrix. |
This is the bounding box radius (x/y/z) of the object, this works for all objects and is faster than manually finding the bounds of even polygon objects, the radius is internally cached.
| Return type: | Vector |
|---|---|
| Returns: | The bounding box width, height and depth. |
Bounding box center (vector), in local space.
| Return type: | Vector |
|---|---|
| Returns: | The bounding box center. |
Set the editor state for this object.
| Parameter: | mode (Vector) – The editor mode:
|
|---|
Set the render state for this object.
| Parameter: | mode (int) – The render mode:
|
|---|
Get a tag of a certain type associated with this object.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The requested tag, or None if no tags of the requested type are available. Note If you request a specific number that is not available then None will be returned even if there is a tag of that type with a different index. |
Removes a tag from the object and free its resources.
| Parameters: |
|
|---|
Get a real spline representation of a primitive spline object. This can for example be used to calculate the length of the spline. If the object is a real spline it returns this. Otherwise None.
Note
The matrix of the returned object mustn’t be used. Use the matrix of self instead.
| Return type: | SplineObject |
|---|---|
| Returns: | The created spline object. |
The object’s visibility depends upon its parent, if it has no visibility track this will return the parent’s visibility which is passed. The range of values are 0.0<=visibility<=1.0.
Note
In the editor only a visibility of 0.0 can be noticed but all other intermediate values are visualized in the renderer only.
| Parameter: | float – The parent objects visibility. |
|---|---|
| Return type: | float |
| Returns: | The visibility. |
Returns the editor state for this object.
| Parameter: | mat (int) – See arguments at BaseObject.SetEditorMode() |
|---|
Returns the render state for this object.
| Parameter: | mat (int) – See arguments at BaseObject.SetRenderMode() |
|---|
Set the state of the deformation/generator tick.
| Parameter: | mode (bool) – True to enable the generator/deformer object. |
|---|
Returns the state of the deformation/generator tick.
| Return type: | bool |
|---|---|
| Returns: | True if the generator/deformer object is enabled. |
Get the ip of the object.
| Return type: | int |
|---|---|
| Returns: | The object IP number. |
Set the ip of the object.
| Parameter: | ip (int) – The object IP number. |
|---|
Set the ip of the object.
| Parameters: |
|
|---|
Returns the first BaseTag of the object.
| Return type: | BaseTag |
|---|---|
| Returns: | Returns the first tag of the object, otherwise False. |
Returns all tags in a list.
| Return type: | list of type BaseTag |
|---|---|
| Returns: | The list of all tags. |
Create and insert a tag for this object.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The new tag. |
Attach a BaseTag to BaseObject.
| Parameters: | |
|---|---|
| Return type: | |
| Returns: | The new tag. |
Returns the count of tags.
| Return type: | int |
|---|---|
| Returns: | Returns the count of tags. |
Get the previously built cache that has been deformed by an active deformer.
It is important to understand the concept of how the deformer cache operates. For each object in the hierarchy that generates a polygonal cache a deformer cache could also have been created by an active deformer object.
A simple example will help to see how this works.
Take the simple hierarchy shown above, the array generator object creates a virtual hierarchy in the cache, this can be retrieved using GetCache. This hierarchy is:
From each of the Cube objects a further cache is generated, this time polygonal:
From these the deformer object generates a deformed polygon cache:
Giving a total hierarchy of:
When a deformer becomes active every object/cache object gets a deform cache (if it was a polygonal object). The deformer cache is always polygonal and is only ever a single object.
It is important to remember that the caches are always built after all plugins and expressions have been called. If you need to get access to the virtual objects to obtain a polygonal based object it is generally advised to use the SendModelingCommand with the MCOMMAND_CURRENTSTATETOOBJECT. This will rebuild the cache for the passed object if needed, and then clone the polygonal objects for you.
Note
You shouldn’t modify the deform cache. Use a deformer ObjectData plugin instead.
| Return type: | BaseObject |
|---|---|
| Returns: | The return may be None if the cache is not available or is not yet built. |
Check if the object has been changed since the last time the object was touched.
| Parameter: | flags (int) – The object part to check
|
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | bool | ||||||||||
| Returns: | Returns True if the object is dirty. |
Check if the object has been changed since the last time the object was touched.
| Parameter: | flags (int) – See parameters at BaseObject.IsDirty() |
|---|
Set the phong smoothing for the object. The object needs a Phong-Tag.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | Success of changing the smoothing. |
Get the previously built cache that has been deformed by an active deformer.
| Return type: | BaseObject |
|---|---|
| Returns: | The objects previously built deformed cache or None. |
Get the object from the previously built cache.
Note
Remember situations can be quite complex in CINEMA 4D. For instance GetCache could return a list of objects. You can use the following helper routine to make things easier. It browses through this rather complex hierarchy of objects and caches recusrsively. Please remember to only use the above routine if you are sure that the caches are really build. It would be for instance not safe to use in a Command plugin since the user could have stoped the scene redraw and the building of caches.
| Parameter: | hierarchyhelp (PyCObject) – A reference to the HierarchyHelp dictionary. |
|---|---|
| Return type: | |
| Returns: | The objects previously built cache or None Note Only for special cases a HierarchyHelp must be passed. |
Check if cache is built, if it matches the requirements (polygonized/isoparm, level of detail etc.). It returns the dirty status of the cache.
Note
This function must only be called within ObjectData.GetVirtualObjects() of a generator object.
| Parameter: | hierarchyhelp (PyCObject) – A reference to the HierarchyHelp dictionary. |
|---|---|
| Return type: | bool |
| Returns: | True if the cache is valid. |
Checks if a highlight handle has been hit, by returning the ID previously returned by ObjectData.DetectHandle(). The handle can then be drawn in the highlight mode.
| Parameter: | bd (BaseDraw) – A base draw. |
|---|---|
| Return type: | int |
| Returns: | The handle ID. |
Start a new dependence list. These enable you to keep track of changes made to any children.
Note
The object must be children of your object.
Compares if anything in the dependence list has changed.
| Return type: | bool |
|---|---|
| Returns: | True if the list has not changed (are the same). |
Add a child object to the dependence list. Usually this will be child objects that are used by a generator object.
| Parameters: |
|
|---|
Check if the object is a child of op.
| Parameter: | op (BaseObject) – Check within this object’s hierarchy. |
|---|---|
| Return type: | bool |
| Returns: | True if the object is a child of op, otherwise False. |