Functions for working with CINEMA 4D’s objects.
Iterator over specific objects in the object manager tree.
Using a depth first traversal scheme, return a tuple in the form (op, lvl), where op is a c4d.BaseObject representing the current object and lvl is an integer indicating the current depth level.
Parameters: |
|
---|
Wraps c4d.BaseObject and makes them hashable, so they can be used as keys in dictionaries.
Parameters: |
|
---|
Represents a hierarchical group structure in the object manager.
Can be used to create a Pythonic snapshot of the current scene so as to provide easy access to specifc sets of objects.
Starting with root object stores a list of c4d.BaseObjects for each depth level in a dictionary. Each list is indexed by a concatenation of its parent names. The concat character is a forward slash, which forms a Unix like filepath as seen with the object manager’s address bar widget.
Additionally, a small subset of X-Path like functionality is provided with the Get() function, namely the subset that coincides with syntax for wildcard and regular epxression expansion. This makes it easy to select a subset of objects, based on parent-name relationships.
Parameters: |
|
---|
Print an indented, tree-like representation of an object manager hierarchy.
Get a list of c4d.BaseObject for the key path given by ‘path’.
Key path can contain wildcards (* or ?) or regular expression syntax. Prepend a ! to path if you want to forego wildcard expansion and thus ensure it is used as a verbatim regular expression pattern instead.
Note that if strict is True, path must match the whole key it is tested against. Otherwise it is sufficient if the path is contained by the key.
Returns a list of all objects for which path, expanded, matches a concatenated parent path.
Returns an empty list if no objects could be located for path.
Same as Select() but uses a slightly different mechanism.
See also BaseDocument.SetSelection(sel, mode).
Not the same as BaseSelect.DeselectAll().
Parameters: | inObjMngr (bool) – if True, run the deselect command for the Object Manager, else the general one for the editor viewport. |
---|
CallCommand based grouping of objects from a list. Generally unreliable, because selection state matters.
Use InsertUnderNull() for better effect.
CallCommand based grouping of selected objects. Generally unreliable, because selection state matters.
Use InsertUnderNull() for better effect.
Return the next object in the hierarchy using a depth-first traversal scheme.
If stop_objs is a c4d.BaseObject or a list of c4d.BaseObjects and the next operation would encounter this object (or the first object in the list) None will be returned. This is so that this function can be used in a while loop.
Same as BaseDocument.GetSelection(), while GetSelection also selects tags and materials.
Find object with name ‘name’.
Parameters: |
|
---|
Find all objects in the scene, either with the name name and/or the unique IP uip.
Returns: | list with matched objects or empty list if no match. |
---|
Create a object of type ‘typ’, with name ‘name’.
This calls c4d.StopAllThreads() internally.
Create object with name ‘name’ removing and replacing any object with the same name.
This calls CreateObject() internally.
Return a new sequential name based on a naming template and a base name such that the name uniquely identifies an object in the scene.
By default, mimicks the names generated by CINEMA 4D when multiple objects of the same type are created in quick succession.
For example if the scene had the following objects:
Cube
Cube.1
Cube.12
Using the default template, the function would return Cube.13 as a new name.
Inserts objects under a group (null) object, optionally creating the group.
Note: currently does not reset obj’s coordinate frame to that of the new parent.
Parameters: |
|
---|
Please remember, like most 3D engines CINEMA 4D handles rotation in radians.
Example for H=10, P=20, B=30:
import c4d
from c4d import utils
# ...
hpb = c4d.Vector(utils.Rad(10), utils.Rad(20), utils.Rad(30))
SetGlobalRotation(obj, hpb) # object's rotation is 10, 20, 30
Set the rotation of the object axis (i.e. keeping points in place).
Parameters: |
|
---|
Courtesy of Scott Ayers (source)
Center the object’s axis.
This is equivalent to moving the object to the new center and then moving all the points back to the old spot.
Parameters: | center (str) – can be midpoint to use the center of the object’s bounding box, or gravity to use the object’s center of gravity. The difference is that in the latter case single points at extreme distances from the object’s core aren’t given as much weight. |
---|
Same as c4d.utils.HPBToMatrix(c4d.utils.VectorToHPB(v)).
Run the Make Editible command on an object or a list of objects.
Parameters: | clone (bool) – if True, return editable clones of the input. |
---|---|
Returns: | editable object or list of editable objects Returns False if the document of the input objects can’t be found. |