The base class of objects.
Here is an example how to create and edit objects:
import c4d
obj = c4d.BaseObject(c4d.Ocube) # Create new cube
obj.SetRelPos(c4d.Vector(20)) # Set position of cube
doc.InsertObject(obj) # Insert object in document
c4d.EventAdd() # Send global event message
Initialize a new BaseObject in memory.
Parameters: | type (int) – The object type : Object Types. |
---|---|
Return type: | BaseObject |
Returns: | The new base object. |
Returns the absolute position of the object. These will be absolute local coordinates within its parent object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The absolute object position. |
Sets the absolute local position of the object within its parent. If the object has no parent then these will be world coordinates. See also Freeze Transformations.
Parameters: | v (Vector) – The absolute object position. |
---|
eturns the absolute scale of the object. These will be relative to the objects parent if it has one. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The absolute object scale. |
Sets the absolute scale of the object relative to its parent object if it has one. See also Freeze Transformations.
Parameters: | v (Vector) – The absolute object scale. |
---|
Returns the absolute HPB rotation of the object relative to any parent object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The absolute object rotation. |
Sets the absolute HPB rotation of the object relative to any parent object. See also Freeze Transformations.
Parameters: | v (Vector) – The absolute object rotation. |
---|
Returns the frozen position of the object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The frozen object position. |
Sets the frozen postion of the object. See also Freeze Transformations.
Parameters: | v (Vector) – The frozen object position. |
---|
Returns the frozen scale of the object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The frozen object scale. |
Sets the frozen scale of the object. See also Freeze Transformations.
Parameters: | v (Vector) – The frozen object scale. |
---|
Returns the frozen HPB rotation of the object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The frozen object rotation. |
Sets the frozen HPB rotation of the object. See also Freeze Transformations.
Parameters: | v (Vector) – The frozen object rotation. |
---|
Returns the relative position of the object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The relative object position. |
Set the relative position of the object. See also Freeze Transformations.
Parameters: | v (Vector) – The relative object position. |
---|
Returns the relative scale of the object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The relative object scale. |
Sets the relative scale of the object. See also Freeze Transformations.
Parameters: | v (Vector) – The relative object scale. |
---|
Returns the relative HPB rotation of the object. See also Freeze Transformations.
Return type: | Vector |
---|---|
Returns: | The relative object rotation. |
Sets the relative HPB rotation of the object. See also Freeze Transformations.
Parameters: | v (Vector) – The relative object rotation. |
---|
Get the local matrix that represents the objects position, scale and rotation.
Return type: | Matrix |
---|---|
Returns: | The object’s local matrix. |
Set the local matrix that represents the objects position, scale and rotation.
Parameters: | m (Matrix) – The object’s new local matrix. |
---|
Returns the frozen and normalized matrix of the object. See also Freeze Transformations.
Parameters: | m (Matrix) – The object’s frozen and normalized matrix. |
---|
Returns the relative and normalized matrix of the object. See also Freeze Transformations.
Return type: | Matrix |
---|---|
Returns: | The object’s relative and normalized matrix. |
Returns the relative matrix of the object. See also Freeze Transformations.
Return type: | Matrix |
---|---|
Returns: | The object’s relative matrix. |
Sets the relative matrix of the object. See also Freeze Transformations.
Parameters: | m (Matrix) – The object’s new relative matrix. |
---|
Get the world (global) matrix that represents the objects position, scale and rotation.
Note
This will only work if the object is attached to a document. Virtual objects in caches and deform caches are not attached to a document, so this function cannot be used for those objects.
Return type: | Matrix |
---|---|
Returns: | The object’s world matrix. |
Set the world (global) matrix that represents the objects position, scale and rotation.
Parameters: | m (Matrix) – The object’s new world matrix. |
---|
Get the local normalized matrix that represents the objects position, scale and rotation.
Return type: | Matrix |
---|---|
Returns: | The object’s normalized local matrix. |
Get the global normalized matrix that represents the objects position, scale and rotation.
Return type: | Matrix |
---|---|
Returns: | The object’s normalized world matrix. |
Get the global matrix of the parent object that represents the objects position, scale and rotation. If the object has no parent object then this matrix will be a unit matrix.
Return type: | Matrix |
---|---|
Returns: | The parent object’s world matrix. |
Copy the matrix to another object.
Parameters: | dst (BaseObject) – The destintation object. |
---|
Bounding box center (vector), in local space.
Return type: | Vector |
---|---|
Returns: | The bounding box center. |
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. |
Returns the state of the editor dot for this object.
Return type: | int | ||||||
---|---|---|---|---|---|---|---|
Returns: |
The editor mode:
|
Set the state of the editor dot for this object.
Parameters: |
mode (int) –
The editor mode:
|
---|
Returns the state of the render dot for this object.
Return type: | int | ||||||
---|---|---|---|---|---|---|---|
Returns: |
The render mode:
|
Set the render state for this object.
Parameters: |
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.
Note
In the editor only a visibility of 0.0 can be noticed but all other intermediate values are visualized in the renderer only.
Parameters: | float – The parent objects visibility. |
---|---|
Return type: | float |
Returns: | The visibility. |
Set the state of the deformation/generator tick.
Parameters: | 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.
Parameters: | ip (int) – The object IP number. |
---|
Set the ip of the object.
Parameters: |
|
---|
Returns the first BaseTag of the object.
Return type: | BaseTag |
---|---|
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. |
Create a variable tag for this object.
Parameters: |
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | |||||||||||||||
Returns: |
The new tag. |
Attach a BaseTag to BaseObject.
Parameters: | |
---|---|
Return type: | |
Returns: |
The new tag. |
Get the variable tag data count.
Parameters: |
type (int) –
The type of tag:
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | int | ||||||||||||||
Returns: | The number of elements in the variable tag. |
Check if the object has been changed since the last time the object was touched.
Parameters: |
flags (int) –
The object part to check
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | bool | ||||||||||
Returns: | True if the object is dirty. |
Check if the object has been changed since the last time the object was touched.
Parameters: | flags (int) – See parameters at IsDirty(). |
---|
Mark object to be used by a generator; automatically resets ‘dirty’.
Set the phong smoothing for the object.
Note
This function will delete any existing Phong tag. If on is set to True it will create a new 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.
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 SendModelingCommand() with 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. |
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.
Parameters: | hierarchyhelp (PyCObject) – A reference to the HierarchyHelp dictionary. |
---|---|
Return type: | BaseObject |
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.
Parameters: | 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.
Parameters: | 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: |
|
---|
Mark all the objects in the dependence list that they will be replaced by the generator.
Check if the object is a child of op.
Parameters: | op (BaseObject) – Check within this object’s hierarchy. |
---|---|
Return type: | bool |
Returns: | True if the object is a child of op, otherwise False. |
Check and generate a clone of the child objects of a parent generator. This is similar to GetHierarchyClone() except that it will check if the hierarchy is dirty and if not it will not need to generate a new clone.
Parameters: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{clone: BaseObject, dirty: bool} |
||||||||||
Returns: |
The cloned object and a dirty flag: True if some part of the child objects in the chain has changed, or False if nothing has changed. |
Generate a clone of the child objects of a parent generator.
The result you get by GetAndCheckHierarchyClone() will be a chain of objects with various types. Passing HIERARCHYCLONEFLAGS_ASLINE e.g. will force all splines to be converted, but not every object in the chain will be of type Oline; some objects like PolygonObject cannot be converted, also there are Onull.
Parameters: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
dict{clone: BaseObject, dirty: bool} |
||||||||||
Returns: |
The cloned object and a dirty flag: True if some part of the child objects in the chain has changed, or False if nothing has changed. |