This object contains the complete description of a scene.
Note
Remember that you need to call StopAllThreads() before making modifications to a user scene.
Return type: | BaseDocument |
---|---|
Returns: | The new document. |
Set the frames per second.
Parameters: | fps (int) – The fps. |
---|
Returns the fps of the document.
Return type: | int |
---|---|
Returns: | The fps |
Get the Level of Detail for this document.
Parameters: |
lod (float) –
The default level of detail values are:
|
---|
Get the Level of Detail for this document.
Return type: | float | ||||||
---|---|---|---|---|---|---|---|
Returns: |
The default level of detail values are:
|
Get if the level of detail for rendering should be used in the editor.
Return type: | bool |
---|---|
Returns: | True if using the render lod. |
Set the level of detail for rendering.
Parameters: | lod (bool) – True if using the render lod. |
---|
Get the editor redraw time.
Return type: | int |
---|---|
Returns: | The editor redraw time. |
Returns the list of layers of the document:
def GetFirstLayer(doc):
"""
Returns the first layer, if
available, otherwise None
"""
return doc.GetLayerObjectRoot().GetDown()
Note
Ensure you only call hierarchy functions on this object like GetDown, ...
Return type: | LayerObject |
---|---|
Returns: | The head of the list of the document’s layers. |
Get the plane in which the splines are created, such as XY plane.
Return type: | int | ||||||
---|---|---|---|---|---|---|---|
Returns: |
Values for this are:
|
New in version R13.016.
Rewinds the whole document (from time 0 to current time) when the next event EVMSG_CHANGE or DrawViews() is processed.
Int flags: | int |
---|---|
Parameters: | flags – Not used. |
Get the BaseDraw count in the editor view.
Return type: | int |
---|---|
Returns: | The count. |
Empties the document, deleting and freeing all resources used.
Set the filename of the document.
Note : | fn must contain the name part only. |
---|---|
Parameters: | type (str) – The filename. |
Set the path of the document.
Note : | fn must contain the path part only. |
---|---|
Parameters: | type (str) – The filename path. |
Returns the filename.
Return type: | str |
---|---|
Returns: | If the document has not been saved then the path is empty. |
Returns the path of the document.
Return type: | str |
---|---|
Returns: | If the document has not been saved then the path is empty. |
Returns the ParticleSystem of the document.
Return type: | ParticleSystem or one |
---|---|
Parameters: | type – The ParticleSystem of the document. Is useless when the document was deleted. Is None if Thinking Particles is not installed. |
New in version R13.016.
Makes sure that GetBaseDraw() (0) is accessible. This is only important in import filters where, at the time, there are no valid base draws.
New in version R13.016.
Finds a scene hook by ID.
Parameters: | id (int) – The scene hook ID. |
---|---|
Return type: | BaseList2D |
Returns: | The found scene hook, or None. |
Tell CINEMA 4D to start building a list of undos into a single undo action for the user, this must be paired with EndUndo().
Return type: | bool |
---|---|
Returns: | Success of starting the undo list. |
Here is a small example how you can write a redo support for new insert objects.:
import c4d
doc.StartUndo() # Start undo support
cube = c4d.BaseObject(c4d.Ocube)
doc.InsertObject(cube) # Insert the object
doc.AddUndo(c4d.UNDOTYPE_NEW, cube) # Support redo the insert operation
doc.EndUndo() # Don't forget to close the undo support
Tell CINEMA 4D to start building a list of undos into a single undo action for the user, this must be paired with an EndUndo().
Parameters: |
|
||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
bool |
||||||||||||||||||||||||||
Returns: |
Success of starting the undo list. |
Returns the element of the last undo action. E.g. if you have added a BaseObject undo you can retrieve the object by calling this method.
Return type: | BaseList2D |
---|---|
Returns: | The last undo element. |
Perform a redo on this document (undo the last undo).
Return type: | bool |
---|---|
Returns: | Success of the operation. |
Perform an undo operation, same as the user selecting Undo from within CINEMA 4D.
Parameters: | multiple (bool) – This parameter only matters if this method is called between AddUndo() and EndUndo(). If multiple is True then all the AddUndo() steps will be undone. Otherwise only the last AddUndo() step will be undone. If EndUndo() has been called then all steps are always undone. |
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
End the building of multiple undo actions into a single user undo, this must be paired with StartUndo().
Return type: | bool |
---|---|
Returns: | Success of finishing the undo list. |
Animate a node in this document at the given time.
Parameters: |
|
---|
Make a clone of the document and turn all objects into polygon based objects.
Parameters: | keepanimation (bool) – Keep animation. |
---|---|
Return type: | BaseDocument |
Returns: | The cloned polygon based document or None if failed. |
Set the starting time for the timeline of this document. For conversion of FPS or other time units, see BaseTime. You may also find the GetFps() useful when using this method.
Parameters: | type (BaseTime) – The time. |
---|
Set the end time of the timline for this document. For conversion of FPS or other time units, see BaseTime. You may also find the GetFps() useful when using this method.
Parameters: | type (BaseTime) – The time. |
---|
Get the starting time for the timeline of this document. For conversion of FPS or other time units, see BaseTime. You may also find the GetFps() useful when using this method.
Return type: | BaseTime |
---|---|
Returns: | The time. |
Get the end time for the timeline of this document. For conversion of FPS or other time units, see BaseTime. You may also find the GetFps() useful when using this method.
Return type: | BaseTime |
---|---|
Returns: | The time. |
Set the current time for this documents timeline.
..note:: This function only changes the document time, it does not start a redraw and/or animation/expressions.
Parameters: | type (BaseTime) – The time. |
---|
Returns the time of the left boundary of the document’s preview range (loop range).
Return type: | BaseTime |
---|---|
Returns: | The time. |
Sets the left boundary of the document’s preview range (loop range) to the given time.
Parameters: | type (BaseTime) – The time. |
---|
Returns the time of the right boundary of the document’s preview range (loop range).
Return type: | BaseTime |
---|---|
Returns: | The time. |
Sets the right boundary of the document’s preview range (loop range) to the given time.
Parameters: | type (BaseTime) – The time. |
---|
Modifies the current multi selection with op, depending on mode.
Parameters: |
|
---|
Sets a tag be the currently active one.
Parameters: |
|
---|
Modifies the current multi selection with op, depending on mode.
Parameters: |
|
---|
Sets the active render settings for the document, these are the settings that are used for rendering.
Parameters: | rd (BaseMaterial) – The render data that you want to make active. |
---|
Returns a collection of all used filename
Return type: | BaseContainer |
---|---|
Returns: | A container with all filenames used by textures in the document. |
Set the current tool in the editor.
Parameters: | a (int) – The values are ID_MODELING_MOVE, ID_MODELING_SCALE, ID_MODELING_ROTATE etc. The IDs are listed in modelingids.h. |
---|
Get the ID of the current active tool in the editor.
Return type: | int |
---|---|
Returns: | The ID. |
Gets the original tool data container. The container is alive until the host object is freed.
Return type: | BaseContainer |
---|---|
Returns: | Tool data container. |
Set the main mode of the editor.
Parameters: |
m (int) –
The value:
|
---|
Get the main mode of the editor.
Return type: | int | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
The value:
|
Check if the editor is in an editable mode. This checks if GetMode() is Mpoints, Medges or Mpolygons.
Return type: | bool |
---|---|
Returns: | True if the editor is in point/poly editing mode. |
Returns the BaseDraw hook of the editor bd.
Parameters: | bd (int) – If there are multiple views (multiple basedraws), this selects the view. |
---|---|
Return type: | BaseDraw |
Returns: | The requested view in the editor, or None |
Get the activate BaseDraw in the editor, this is where all drawing should be performed.
Return type: | BaseDraw |
---|---|
Returns: | The active view in the editor. |
This is the BaseDraw belonging to the view that the user has chosen as ‘Render View’ (see View menu in CINEMA).
Return type: | BaseDraw |
---|---|
Returns: | The render view in the editor. |
Returns the active selected tag.
Return type: | BaseTag |
---|---|
Returns: | The active tag, or None. |
Returns all materials in a list.
Return type: | list of type BaseMaterial |
---|---|
Returns: | The list of all materials. |
Returns the active selected object.
Return type: | BaseObject |
---|---|
Returns: | The active object, or None. |
Returns the active selected render data.
Return type: | RenderData |
---|---|
Returns: |
The active render data.
Note Guaranteed to never be None. |
Get the first render setting data RenderData for this document. The other render settings in the document can be accessed by using the base class list functions, RenderData.GetNext().
Return type: | RenderData |
---|---|
Returns: | The first render setting, or None if no render settings are associated with this document. |
Inserts the render setting data into the document’s render setting list. Optionally you can specify the insertion position with the pred parameter, giving the render setting before (right above) the wanted position. Otherwise the render setting is inserted at the first position in the list.
Parameters: |
|
---|
Inserts the render data as last child into the document’s render data list.
Parameters: |
|
---|
Returns the active selected material.
Return type: | BaseMaterial |
---|---|
Returns: | The active material, or None. |
Get the BaseContainer setting of the specified type.
Parameters: |
type (int) –
Selects the type of the setting to set.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | BaseContainer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns: | The settings of this document. |
Merge the BaseContainer for the specified settings.
Parameters: |
|
---|
Returns the internal settings object. Changes to the returned container are reflected in the document.
Parameters: |
int (type) –
Selects the type of settings to get for this document:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | BaseContainer |
:return. The settings container.
Returns the first object.
Return type: | BaseObject |
---|---|
Returns: | The first object, or None if no objects are contained in this document. |
Returns the first material.
Return type: | BaseMaterial |
---|---|
Returns: | The active material, or None. |
Returns the material selection.
Return type: | list of type BaseMaterial |
---|---|
Returns: | The selected materials in a list. |
Deprecated since version R13.051.
Use GetActiveObjects() with the corresponding flag instead.
Returns the objects in an ordered list.
Return type: | list of BaseList2D |
---|---|
Returns: | The oredered list. |
Returns the object selection.
Parameters: |
flags (int) –
Changed in version R13.051: Replaced argument children by flags, downward compatible. Flags:
|
||||||
---|---|---|---|---|---|---|---|
Return type: | list of type BaseList2D | ||||||
Returns: | The selected objects in a list. |
Returns the tag selection.
Return type: | list of type BaseTag |
---|---|
Returns: | The selected tags in a list. |
Returns the selection of materials, tags and objects in a list.
Return type: | list of type BaseList2D |
---|---|
Returns: | The selected objects in a list. |
New in version R13.016.
Returns the active object multi selection and removes objects that don’t match the filter given by type and instanceof.
Parameters: |
|
---|---|
Return type: |
list of type BaseList2D |
Returns: |
The selected objects in a list. |
Returns the highest objects without children.
Return type: | list of type BaseObject |
---|---|
Returns: | The objects. |
Sets the active selection. This function deals with both objects, tags and materials.
Parameters: |
|
---|
Search for a material with the same case sensitive name.
Parameters: | name (str) – The name of the material to search for. |
---|---|
Return type: | BaseMaterial |
Returns: | The material or None if nothing was found. |
Search for a material with the closest matching name.
Parameters: | name (str) – The name of the material to search for. |
---|---|
Return type: | BaseMaterial |
Returns: | The material or None if nothing was found. |
Search for an object with the same case sensitive name.
Parameters: | name (str) – The name of the object to search for. |
---|---|
Return type: | BaseObject |
Returns: | The object or None if nothing was found. |
Search for an object with the closest name.
Parameters: | name (str) – The name of the object to search for. |
---|---|
Return type: | BaseObject |
Returns: | The object or None if nothing was found. |
The first object in object manager hierarchy of type type. It searches objects that are not deactivated in the object manager (set to red).
Parameters: |
|
---|---|
Return type: | |
Returns: |
The first requested object or None if nothing was found. |
Note
If both pred and parent are provided then pred has precedence.
Inserts the object into the document’s object hierarchy. The insertion position can either be specified by the parent parameter, inserting the object as the first child of the specified parent, or by the pred parameter, inserting the object below the specified prev object. If neither is given, the object is inserted at the top of the hierarchy.
Raises ReferenceError: | |
---|---|
If the passed objects (parent and pred) are not in the same document. |
|
Parameters: |
|
Inserts the material into the document’s material list. Optionally you can specify the insertion position with the pred parameter, giving the material before (just to the left of) the wanted position. Otherwise the material is inserted at the first position in the list.
Parameters: |
|
---|
The helper axis for the current multi selection.
Return type: | BaseObject |
---|---|
Returns: | The axis object. |
Returns True if the document has been changed since it was last saved.
Return type: | bool |
---|---|
Returns: | True if the document has been changed. |
Set changed state of the document to reflect it has been modified.
Sometimes you want to cache stuff and browse through the time of a document. The following code snippet shows you how to do it in the best way:
import c4d
from c4d import documents
def BrowseDoc(doc):
""" Pass the document you want to run the time through"""
ctime = doc.GetTime() # Save current time
fps = doc.GetFps()
start = doc.GetMinTime().GetFrame(fps) #Set minimum time
until = doc.GetMaxTime().GetFrame(fps)
for f in xrange(start, until):
c4d.StatusSetBar(100*(f-start)/(until-start))
doc.SetTime(c4d.BaseTime(f, fps))
c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW|c4d.DRAWFLAGS_NO_THREAD|c4d.DRAWFLAGS_NO_REDUCTION|c4d.DRAWFLAGS_STATICBREAK)
# Do your caching here
# 'f' is the current frame
c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) # Update timeline
doc.SetTime(ctime) #set time back
c4d.EventAdd(c4d.EVENT_ANIMATE)
c4d.StatusClear()