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

c4d.BaseObject – a base object class

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
../../../../../../_images/main2.png

The base class of objects.

class c4d.BaseObject

// Coordinates info

// Other stuff

//Still private

  • BaseObject.GetAndCheckHierarchyClone()
  • BaseObject.GetHierarchyClone()

SuperClass

BaseList2D

Methods

static BaseObject.__init__(type)
Parameter:type (int) – The id of the object, e.g: (Ocube). See also: Types
Return type:BaseObject
Returns:The new base object.
BaseObject.GetPos()

Returns the position of the object.

Return type:Vector
Returns:The position.
BaseObject.SetPos(vec)

Set the position of the object.

Parameter:pos (Vector) – The position.
BaseObject.GetScale()

Returns the scale of the object.

Return type:Vector
Returns:The scale.
BaseObject.SetScale(vec)

Set the scale of the object.

Parameter:pos (Vector) – The scale.
BaseObject.GetRot()

Returns the rotation of the object.

Return type:Vector
Returns:The rotation.
BaseObject.SetRot(vec)

Set the rotation of the object.

Parameter:pos (Vector) – The rotation.
BaseObject.GetMl()

Returns the local matrix that represents the objects position, scale and rotation

Return type:Matrix
Returns:The matrix.
BaseObject.SetMl(mat[, force=True])

Set the local matrix that represents the objects position, scale and rotation.

Parameters:
  • mat (Matrix) – The matrix.
  • force (bool) – The ‘compensation matrix’ that is multiplied to the pos/scale/rotation matrix. The compensation matrix allows to set distored, mirrored etc. axis systems (that wouldn’t be possible otherwise as pos/scale/rot always generate a left-hand rectangular system). The problem is that when expressions/algorithms frequently read/write global/local matrices the compensation matrix sums up calculation inaccuracies. This results in more and more distorted systems. To avoid this you can set force to False: it then only affects pos/scale/rot and keeps the old compensation matrix.
BaseObject.GetMg()

Returns the global matrix that represents the objects position, scale and rotation

Return type:Matrix
Returns:The matrix.
BaseObject.SetMg(mat[, force=True])

Set the global matrix that represents the objects position, scale and rotation.

Parameters:
  • mat (Matrix) – The matrix.
  • force (bool) – The ‘compensation matrix’ that is multiplied to the pos/scale/rotation matrix. The compensation matrix allows to set distored, mirrored etc. axis systems (that wouldn’t be possible otherwise as pos/scale/rot always generate a left-hand rectangular system). The problem is that when expressions/algorithms frequently read/write global/local matrices the compensation matrix sums up calculation inaccuracies. This results in more and more distorted systems. To avoid this you can set force to False: it then only affects pos/scale/rot and keeps the old compensation matrix.
BaseObject.GetMln()

Returns the local normalized matrix that represents the objects position, scale and rotation

Return type:Matrix
Returns:The matrix.
BaseObject.GetRad()

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.
BaseObject.GetMp()

Bounding box center (vector), in local space.

Return type:Vector
Returns:The bounding box center.
BaseObject.SetEditorMode(mode)

Set the editor state for this object.

Parameter:mode (Vector) –

The editor mode:

MODE_ON The object is enabled regardless of the state of any parent objects.
MODE_OFF The object is disabled regardless of the state of any parent objects.
MODE_UNDEF The object is enabled by default, but the state of the parent objects is used if they are enabled or disabled.
BaseObject.SetRenderMode(mode)

Set the render state for this object.

Parameter:mode (int) –

The render mode:

MODE_ON The object is enabled regardless of the state of any parent objects.
MODE_OFF The object is disabled regardless of the state of any parent objects.
MODE_UNDEF The object is enabled by default, but the state of the parent objects is used if they are enabled or disabled.
BaseObject.GetTag(type[, nr=0])

Get a tag of a certain type associated with this object.

Parameters:
  • type (int) – The type of tag to fetch from the object:
  • nr (int) – The starting tag index to find of this type.
Return type:

BaseTag

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.

BaseObject.KillTag(type[, nr=0])

Removes a tag from the object and free its resources.

Parameters:
  • type (int) – The type of tag to fetch from the object:
  • nr (int) – The starting tag index to find of this type.
BaseObject.GetRealSpline()

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.
BaseObject.GetVisibility(parent)

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.
BaseObject.GetEditorMode()

Returns the editor state for this object.

Parameter:mat (int) – See arguments at BaseObject.SetEditorMode()
BaseObject.GetRenderMode()

Returns the render state for this object.

Parameter:mat (int) – See arguments at BaseObject.SetRenderMode()
BaseObject.SetDeformMode(mode)

Set the state of the deformation/generator tick.

Parameter:mode (bool) – True to enable the generator/deformer object.
BaseObject.GetDeformMode()

Returns the state of the deformation/generator tick.

Return type:bool
Returns:True if the generator/deformer object is enabled.
BaseObject.GetUniqueIP()

Get the ip of the object.

Return type:int
Returns:The object IP number.
BaseObject.SetUniqueIP(ip)

Set the ip of the object.

Parameter:ip (int) – The object IP number.
BaseObject.CopyTagsTo(dest, visible, variable, hierarchial)

Set the ip of the object.

Parameters:
  • dest (BaseObject) – The destination object where to copy all tags from self.
  • visible (bool) – True if the tag is visible.
  • variable (bool) – True if the tag must be variable.
  • hierarchial (bool) – True if the tag must be hierarchial.
BaseObject.GetFirstTag()

Returns the first BaseTag of the object.

Return type:BaseTag
Returns:Returns the first tag of the object, otherwise False.
BaseObject.GetTags()

Returns all tags in a list.

Return type:list of type BaseTag
Returns:The list of all tags.
BaseObject.MakeTag(x[, pred])

Create and insert a tag for this object.

Parameters:
  • x (int) – The type of tag to create
  • pred (BaseTag) – The tag will insert after prev.
Return type:

BaseTag

Returns:

The new tag.

BaseObject.InsertTag(tp[, pred=None])

Attach a BaseTag to BaseObject.

Parameters:
  • tp (BaseTag) – The tag which will be attached.
  • pred (BaseTag) – tp will insert after pred.
Return type:

BaseTag

Returns:

The new tag.

BaseObject.GetTagCount()

Returns the count of tags.

Return type:int
Returns:Returns the count of tags.
BaseObject.GetDeformCache()

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.

../../../../../../_images/cache_arraycube1.png

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:

../../../../../../_images/cache_arraycube2.png

From each of the Cube objects a further cache is generated, this time polygonal:

../../../../../../_images/cache_arraycube3.png

From these the deformer object generates a deformed polygon cache:

../../../../../../_images/cache_arraycube4.png

Giving a total hierarchy of:

../../../../../../_images/cache_arraycube5.png

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.
BaseObject.IsDirty(flags)

Check if the object has been changed since the last time the object was touched.

Parameter:flags (int) –

The object part to check

DIRTY_MATRIX The matrix was changed.
DIRTY_DATA The container was changed.
DIRTY_SELECT Checks all valid selections of the object, e.g. points, edge, polys.
DIRTY_CACHE Checks if the cache was rebuilt.
DIRTY_CHILDREN The children are dirty.
Return type:bool
Returns:Returns True if the object is dirty.
BaseObject.SetDirty(flags)

Check if the object has been changed since the last time the object was touched.

Parameter:flags (int) – See parameters at BaseObject.IsDirty()
BaseObject.Touch()
Mark object to be used by a generator; automatically resets ‘dirty’.
BaseObject.SetPhong(on, anglelimit, angle)

Set the phong smoothing for the object. The object needs a Phong-Tag.

Parameters:
  • on (bool) – False removes the phong tag from the object.
  • anglelimit (bool) – Maximum anglelimit
  • angle (int) – The angle.
Return type:

bool

Returns:

Success of changing the smoothing.

BaseObject.GetDeformCache()

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.
BaseObject.GetCache(hierarchyhelp)

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:

BaseObject

Returns:

The objects previously built cache or None

Note

Only for special cases a HierarchyHelp must be passed.

BaseObject.CheckCache(hierarchyhelp)

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.
BaseObject.GetHighlightHandle(bd)

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.
BaseObject.NewDependenceList()

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.

BaseObject.CompareDependenceList()

Compares if anything in the dependence list has changed.

Return type:bool
Returns:True if the list has not changed (are the same).
BaseObject.AddDependence(hh, op)

Add a child object to the dependence list. Usually this will be child objects that are used by a generator object.

Parameters:
BaseObject.TouchDependenceList()
Mark all the objects in the dependence list that they will be replaced by the generator.
BaseObject.SearchHierarchy(op)

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.

Table Of Contents

This Page