c4d.documents.BaseDocument

This object contains the complete description of a scene.

Note

Remember that you need to call StopAllThreads() before making modifications to a user scene.

Definition

class c4d.documents.BaseDocument

Inheritance

Members

BaseDocument.__init__()
Return type: BaseDocument
Returns: The new document.
BaseDocument.SetFps(fps)

Set the frames per second.

Parameters: fps (int) – The fps.
BaseDocument.GetFps()

Returns the fps of the document.

Return type: int
Returns: The fps
BaseDocument.SetLOD(lod)

Get the Level of Detail for this document.

Parameters: lod (float) –

The default level of detail values are:

Low 0.25
Medium 0.5
High 1.0
BaseDocument.GetLOD()

Get the Level of Detail for this document.

Return type: float
Returns: The default level of detail values are:
Low 0.25
Medium 0.5
High 1.0
BaseDocument.GetRenderLod()

Get if the level of detail for rendering should be used in the editor.

Return type: bool
Returns: True if using the render lod.
BaseDocument.SetRenderLod(lod)

Set the level of detail for rendering.

Parameters: lod (bool) – True if using the render lod.
BaseDocument.GetDrawTime()

Get the editor redraw time.

Return type: int
Returns: The editor redraw time.
BaseDocument.GetLayerObjectRoot()

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.
BaseDocument.GetSplinePlane()

Get the plane in which the splines are created, such as XY plane.

Return type: int
Returns: Values for this are:
PRIM_PLANE_XY XY plane.
PRIM_PLANE_ZY ZY plane.
PRIM_PLANE_XZ XZ plane.
BaseDocument.SetRewind([flags=0])

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.
BaseDocument.GetBaseDrawCount()

Get the BaseDraw count in the editor view.

Return type: int
Returns: The count.
BaseDocument.Flush()

Empties the document, deleting and freeing all resources used.

BaseDocument.SetDocumentName(name)

Set the filename of the document.

Note : fn must contain the name part only.
Parameters: type (str) – The filename.
BaseDocument.SetDocumentPath(path)

Set the path of the document.

Note : fn must contain the path part only.
Parameters: type (str) – The filename path.
BaseDocument.GetDocumentName()

Returns the filename.

Return type: str
Returns: If the document has not been saved then the path is empty.
BaseDocument.GetDocumentPath()

Returns the path of the document.

Return type: str
Returns: If the document has not been saved then the path is empty.
BaseDocument.GetParticleSystem()

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.
BaseDocument.ForceCreateBaseDraw()

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.

BaseDocument.FindSceneHook(id)

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.
BaseDocument.StartUndo()

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
BaseDocument.AddUndo(type, data)

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:
  • type (int) –

    Value for this are:

    UNDOTYPE_0 No flags.
    UNDOTYPE_CHANGE Any change to an object, including hierarchy modifications; modification in positioning (object has been moved from A to B), substructures etc. (Needs to be called BEFORE action.)
    UNDOTYPE_CHANGE_NOCHILDREN Same as UNDOTYPE_CHANGE, but without child modifications. (Needs to be called BEFORE action.)
    UNDOTYPE_CHANGE_SMALL Change to local data only (e.g. data container), no substructures (e.g. no tags on an object). Also no children. (Needs to be called BEFORE action.)
    UNDOTYPE_CHANGE_SELECTION Change to point/poly/edge selection only. (Needs to be called BEFORE action.)
    UNDOTYPE_NEW New object/node/tag etc. was created. (Needs to be called AFTER action.)
    UNDOTYPE_DELETE Object/node/tag etc. to be deleted. (Needs to be called BEFORE action.)
    UNDOTYPE_ACTIVATE Automatically managed by SetActiveObject()/Tag()/Material() etc. No need to use manually.
    UNDOTYPE_DEACTIVATE Automatically managed by SetActiveObject()/Tag()/Material() etc. No need to use manually.
    UNDOTYPE_BITS Change to object bits, e.g. selection status.
    UNDOTYPE_PRIVATE_MULTISELECTIONAXIS Private.
    UNDOTYPE_START Private.
    UNDOTYPE_END Private.
  • data (BaseList2D) – The object.
Return type:

bool

Returns:

Success of starting the undo list.

BaseDocument.GetUndoObject()

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.
BaseDocument.DoRedo()

Perform a redo on this document (undo the last undo).

Return type: bool
Returns: Success of the operation.
BaseDocument.DoUndo([multiple=False])

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.
BaseDocument.EndUndo()

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.
BaseDocument.AnimateObject(op, time, flags)

Animate a node in this document at the given time.

Parameters:
  • op (BaseList2D) – This is the node to animate.
  • time (BaseTime) – The time at which it is being animated.
  • flags (int) –

    The flags are:

    ANIMATEFLAGS_0 No flags.
    ANIMATEFLAGS_NO_PARTICLES Ignore particles.
    ANIMATEFLAGS_QUICK Only fast tracks, e.g. not morphing. (Checks the ANIMINFO_QUICK bit of animation plugins.)
    ANIMATEFLAGS_NO_CHILDS Don’t animate children.
    ANIMATEFLAGS_INRENDER Prepare to render scene.
    ANIMATEFLAGS_NO_MINMAX Private.
    ANIMATEFLAGS_NO_NLA Private.
    ANIMATEFLAGS_NLA_SUM Private.
BaseDocument.Polygonize(keepanimation)

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.
BaseDocument.SetMinTime(time)

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.
BaseDocument.SetMaxTime(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.
BaseDocument.GetMinTime()

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.
BaseDocument.GetMaxTime()

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.
BaseDocument.GetTime()

Returns the min time.

Return type: BaseTime
Returns: The current time.
BaseDocument.SetTime(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.
BaseDocument.GetLoopMinTime()

Returns the time of the left boundary of the document’s preview range (loop range).

Return type: BaseTime
Returns: The time.
BaseDocument.SetLoopMinTime(time)

Sets the left boundary of the document’s preview range (loop range) to the given time.

Parameters: type (BaseTime) – The time.
BaseDocument.GetLoopMaxTime()

Returns the time of the right boundary of the document’s preview range (loop range).

Return type: BaseTime
Returns: The time.
BaseDocument.SetLoopMaxTime(time)

Sets the right boundary of the document’s preview range (loop range) to the given time.

Parameters: type (BaseTime) – The time.
BaseDocument.SetActiveObject(op[, mode=SELECTION_NEW])

Modifies the current multi selection with op, depending on mode.

Parameters:
  • op (BaseObject) – The object.
  • mode (int) –

    The selection flag:

    SELECTION_NEW Starts a new selection.
    SELECTION_ADD Adds to the current selection
    SELECTION_SUB Subtracts from the current selection.
BaseDocument.SetActiveTag(tag[, mode=SELECTION_NEW])

Sets a tag be the currently active one.

Parameters:
  • tag (BaseTag) – The tag to set active.
  • mode (int) –

    The selection flag:

    SELECTION_NEW Starts a new selection.
    SELECTION_ADD Adds to the current selection
    SELECTION_SUB Subtracts from the current selection.
BaseDocument.SetActiveMaterial(mp[, mode=SELECTION_NEW])

Modifies the current multi selection with op, depending on mode.

Parameters:
  • mp (BaseMaterial) – The material to set active.
  • mode (int) –

    The selection flag:

    SELECTION_NEW Starts a new selection.
    SELECTION_ADD Adds to the current selection
    SELECTION_SUB Subtracts from the current selection.
BaseDocument.SetActiveRenderData(rd)

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.
BaseDocument.GetAllTextures()

Returns a collection of all used filename

Return type: BaseContainer
Returns: A container with all filenames used by textures in the document.
BaseDocument.SetAction(a)

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.
BaseDocument.GetAction()

Get the ID of the current active tool in the editor.

Return type: int
Returns: The ID.
BaseDocument.GetActiveToolData()

Gets the original tool data container. The container is alive until the host object is freed.

Return type: BaseContainer
Returns: Tool data container.
BaseDocument.SetMode(m)

Set the main mode of the editor.

Parameters: m (int) –

The value:

Mcamera Camera mode.
Mobject Object mode.
Mtexture Texture mode.
Mtextureaxis Texture axis mode.
Mpoints Point edit mode.
Medges Edge edit mode.
Mpolygons Polygon edit mode.
Manimation Animation mode.
Mkinematic IK mode.
Mmodel Model mode.
Mpaint Paint mode.
Muvpoints UV points.
Muvpolygons UV polygons.
Mdrag Drag mode.
Mpolyedgepoint Combined poly/edge/point mode. Must only be used in ViewportSelect.
Medgepoint Combined edge/point mode. Must only be used in ViewportSelect.
BaseDocument.GetMode()

Get the main mode of the editor.

Return type: int
Returns: The value:
Mcamera Camera mode.
Mobject Object mode.
Mtexture Texture mode.
Mtextureaxis Texture axis mode.
Mpoints Point edit mode.
Medges Edge edit mode.
Mpolygons Polygon edit mode.
Manimation Animation mode.
Mkinematic IK mode.
Mmodel Model mode.
Mpaint Paint mode.
Muvpoints UV points.
Muvpolygons UV polygons.
Mdrag Drag mode.
Mpolyedgepoint Combined poly/edge/point mode. Must only be used in ViewportSelect.
Medgepoint Combined edge/point mode. Must only be used in ViewportSelect.
BaseDocument.IsEditMode()

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.
BaseDocument.GetBaseDraw(bd)

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
BaseDocument.GetActiveBaseDraw()

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.
BaseDocument.GetRenderBaseDraw()

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.
BaseDocument.GetActiveTag()

Returns the active selected tag.

Return type: BaseTag
Returns: The active tag, or None.
BaseDocument.GetMaterials()

Returns all materials in a list.

Return type: list of type BaseMaterial
Returns: The list of all materials.
BaseDocument.GetActiveObject()

Returns the active selected object.

Return type: BaseObject
Returns: The active object, or None.
BaseDocument.GetActiveRenderData()

Returns the active selected render data.

Return type: RenderData
Returns: The active render data.

Note

Guaranteed to never be None.

BaseDocument.GetFirstRenderData()

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.
BaseDocument.InsertRenderData(rd[, pred=None])

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:
  • rd (RenderData) – Render setting data to insert.
  • pred (RenderData) – Optional point to insert the render settings data
BaseDocument.InsertRenderDataLast(rd)

Inserts the render data as last child into the document’s render data list.

Parameters:
  • rd (RenderData) – Render setting data to insert.
  • pred (RenderData) – Optional point to insert the render settings data
BaseDocument.GetActiveMaterial()

Returns the active selected material.

Return type: BaseMaterial
Returns: The active material, or None.
BaseDocument.GetData([type])

Get the BaseContainer setting of the specified type.

Parameters: type (int) –

Selects the type of the setting to set.

  • DOCUMENTSETTINGS_GENERAL
General settings.
DOCUMENT_TIME BaseTime Current document time.
DOCUMENT_FPS int Frame rate (frames per second).
DOCUMENT_MINTIME BaseTime Start time.
DOCUMENT_MAXTIME BaseTime End time.
DOCUMENT_LOOPMINTIME BaseTime Start preview (loop) time.
DOCUMENT_LOOPMAXTIME BaseTime End preview (loop) time.
DOCUMENT_LOD float Level of detail (0-100%).
DOCUMENT_RENDERLOD bool Render LOD in editor.
DOCUMENT_USEANIMATION bool Use animation.
DOCUMENT_USEEXPRESSIONS bool Use expressions.
DOCUMENT_USEGENERATORS bool Use generators.
DOCUMENT_USEDEFORMERS bool Use deformers.
DOCUMENT_MODE bool Editor mode.
  Mcamera Camera mode.
  Mobject Object mode.
  Mtexture Texture mode.
  Mtextureaxis Texture axis mode.
  Mpoints Point edit mode.
  Medges Edge edit mode.
  Mpolygons Polygon edit mode.
  Manimation Animation mode.
  Mkinematic IK mode.
  Mmodel Model mode.
  Mpaint Paint mode.
  Muvpoints UV points.
  Muvpolygons UV polygons.
  Mdrag Drag mode.
  Mpolyedgepoint Combined poly/edge/point mode. Must only be used in ViewportSelect.
  Medgepoint Combined edge/point mode. Must only be used in ViewportSelect.
DOCUMENT_ACTION int ID of the current tool.
DOCUMENT_USERCHANGE bool Private.
DOCUMENT_PATH str Document file path.
DOCUMENT_NAME str Name of the document.
DOCUMENT_STATEX bool Lock/unlock X-axis.
DOCUMENT_STATEY bool Lock/unlock Y-axis.
DOCUMENT_STATEZ bool Lock/unlock Z-axis.
DOCUMENT_STATEW bool Use world/object coordinate system.
  • DOCUMENTSETTINGS_MODELING
Modeler settings.
See MDATA_Options and toolsnapping.h
  • DOCUMENTSETTINGS_DOCUMENT
Document settings.
DOCUMENT_COLORPROFILE int Input color profile.
  DOCUMENT_COLORPROFILE_SRGB sRGB.
  DOCUMENT_COLORPROFILE_LINEAR Linear.
  DOCUMENT_COLORPROFILE_DISABLED Disabled.
DOCUMENT_LINEARWORKFLOW bool Use linear workflow.
DOCUMENT_DOCUNIT UnitScaleData Document scale.
DOCUMENT_DEFAULTMATERIAL_TYPE int Default object color preset.
  DOCUMENT_DEFAULTMATERIAL_TYPE_WHITE 80% Gray.
  DOCUMENT_DEFAULTMATERIAL_TYPE_BLUE Gray-Blue.
  DOCUMENT_DEFAULTMATERIAL_TYPE_USER Custom.
DOCUMENT_DEFAULTMATERIAL_COLOR Vector Default object color.
DOCUMENT_CLIPPING_PRESET int View clipping preset.
  DOCUMENT_CLIPPING_PRESET_TINY Tiny.
  DOCUMENT_CLIPPING_PRESET_SMALL Small.
  DOCUMENT_CLIPPING_PRESET_MEDIUM Medium.
  DOCUMENT_CLIPPING_PRESET_LARGE Large.
  DOCUMENT_CLIPPING_PRESET_HUGE Huge.
  DOCUMENT_CLIPPING_PRESET_CUSTOM Custom.
DOCUMENT_CLIPPING_PRESET_NEAR float Near view clipping.
DOCUMENT_CLIPPING_PRESET_FAR float Far view clipping.
DOCUMENT_SELECTIONFILTER int Selection filter bit mask.
  SELECTIONFILTERBIT_0 None.
  SELECTIONFILTERBIT_NULL Null.
  SELECTIONFILTERBIT_POLYGON Polygon.
  SELECTIONFILTERBIT_SPLINE Spline.
  SELECTIONFILTERBIT_GENERATOR Generator.
  SELECTIONFILTERBIT_HYPERNURBS HyperNURBS.
  SELECTIONFILTERBIT_DEFORMER Deformer.
  SELECTIONFILTERBIT_CAMERA Camera.
  SELECTIONFILTERBIT_LIGHT Light.
  SELECTIONFILTERBIT_SCENE Scene.
  SELECTIONFILTERBIT_PARTICLE Particle.
  SELECTIONFILTERBIT_OTHER Other.
  SELECTIONFILTERBIT_JOINT Joint.
DOCUMENT_RESTRICTEDITORSELECTION bool Restrict editor selection (Selection objects).
DOCUMENT_INFO_DATECREATED long Creation date.
DOCUMENT_INFO_PRGCREATOR_NAME str Name of the creation software.
DOCUMENT_INFO_PRGCREATOR_ID int ID of the creation software.
  MAXON_CREATOR_ID MAXON.
DOCUMENT_MULTISELECTIONHIGHLIGHT BaseLink Private.
DOCUMENT_INFO_AUTHOR str Document author.
DOCUMENT_INFO_COPYRIGHT str Copyright info.
DOCUMENT_INFO_README str Info string.
DOCUMENT_INFO_DATESAVED long Last save date.
DOCUMENT_INFO_PRGWRITER_NAME str Software the document was saved last.
DOCUMENT_INFO_PRGWRITER_ID int ID of the software the document was saved last.
  MAXON_CREATOR_ID MAXON.
  • DOCUMENTSETTINGS_ANIMATIONSYSTEM
Time line settings. (Private!)
  • DOCUMENTSETTINGS_TOOLS
Tools settings. (Unused)
Return type: BaseContainer
Returns: The settings of this document.
BaseDocument.SetData(type, bc)

Merge the BaseContainer for the specified settings.

Parameters:
  • type (int) –

    Selects the type of the setting to set.

    • DOCUMENTSETTINGS_GENERAL
    General settings.
    DOCUMENT_TIME BaseTime Current document time.
    DOCUMENT_FPS int Frame rate (frames per second).
    DOCUMENT_MINTIME BaseTime Start time.
    DOCUMENT_MAXTIME BaseTime End time.
    DOCUMENT_LOOPMINTIME BaseTime Start preview (loop) time.
    DOCUMENT_LOOPMAXTIME BaseTime End preview (loop) time.
    DOCUMENT_LOD float Level of detail (0-100%).
    DOCUMENT_RENDERLOD bool Render LOD in editor.
    DOCUMENT_USEANIMATION bool Use animation.
    DOCUMENT_USEEXPRESSIONS bool Use expressions.
    DOCUMENT_USEGENERATORS bool Use generators.
    DOCUMENT_USEDEFORMERS bool Use deformers.
    DOCUMENT_MODE bool Editor mode.
      Mcamera Camera mode.
      Mobject Object mode.
      Mtexture Texture mode.
      Mtextureaxis Texture axis mode.
      Mpoints Point edit mode.
      Medges Edge edit mode.
      Mpolygons Polygon edit mode.
      Manimation Animation mode.
      Mkinematic IK mode.
      Mmodel Model mode.
      Mpaint Paint mode.
      Muvpoints UV points.
      Muvpolygons UV polygons.
      Mdrag Drag mode.
      Mpolyedgepoint Combined poly/edge/point mode. Must only be used in ViewportSelect.
      Medgepoint Combined edge/point mode. Must only be used in ViewportSelect.
    DOCUMENT_ACTION int ID of the current tool.
    DOCUMENT_USERCHANGE bool Private.
    DOCUMENT_PATH str Document file path.
    DOCUMENT_NAME str Name of the document.
    DOCUMENT_STATEX bool Lock/unlock X-axis.
    DOCUMENT_STATEY bool Lock/unlock Y-axis.
    DOCUMENT_STATEZ bool Lock/unlock Z-axis.
    DOCUMENT_STATEW bool Use world/object coordinate system.
    • DOCUMENTSETTINGS_MODELING
    Modeler settings.
    See MDATA_Options and toolsnapping.h
    • DOCUMENTSETTINGS_DOCUMENT
    Document settings.
    DOCUMENT_COLORPROFILE int Input color profile.
      DOCUMENT_COLORPROFILE_SRGB sRGB.
      DOCUMENT_COLORPROFILE_LINEAR Linear.
      DOCUMENT_COLORPROFILE_DISABLED Disabled.
    DOCUMENT_LINEARWORKFLOW bool Use linear workflow.
    DOCUMENT_DOCUNIT UnitScaleData Document scale.
    DOCUMENT_DEFAULTMATERIAL_TYPE int Default object color preset.
      DOCUMENT_DEFAULTMATERIAL_TYPE_WHITE 80% Gray.
      DOCUMENT_DEFAULTMATERIAL_TYPE_BLUE Gray-Blue.
      DOCUMENT_DEFAULTMATERIAL_TYPE_USER Custom.
    DOCUMENT_DEFAULTMATERIAL_COLOR Vector Default object color.
    DOCUMENT_CLIPPING_PRESET int View clipping preset.
      DOCUMENT_CLIPPING_PRESET_TINY Tiny.
      DOCUMENT_CLIPPING_PRESET_SMALL Small.
      DOCUMENT_CLIPPING_PRESET_MEDIUM Medium.
      DOCUMENT_CLIPPING_PRESET_LARGE Large.
      DOCUMENT_CLIPPING_PRESET_HUGE Huge.
      DOCUMENT_CLIPPING_PRESET_CUSTOM Custom.
    DOCUMENT_CLIPPING_PRESET_NEAR float Near view clipping.
    DOCUMENT_CLIPPING_PRESET_FAR float Far view clipping.
    DOCUMENT_SELECTIONFILTER int Selection filter bit mask.
      SELECTIONFILTERBIT_0 None.
      SELECTIONFILTERBIT_NULL Null.
      SELECTIONFILTERBIT_POLYGON Polygon.
      SELECTIONFILTERBIT_SPLINE Spline.
      SELECTIONFILTERBIT_GENERATOR Generator.
      SELECTIONFILTERBIT_HYPERNURBS HyperNURBS.
      SELECTIONFILTERBIT_DEFORMER Deformer.
      SELECTIONFILTERBIT_CAMERA Camera.
      SELECTIONFILTERBIT_LIGHT Light.
      SELECTIONFILTERBIT_SCENE Scene.
      SELECTIONFILTERBIT_PARTICLE Particle.
      SELECTIONFILTERBIT_OTHER Other.
      SELECTIONFILTERBIT_JOINT Joint.
    DOCUMENT_RESTRICTEDITORSELECTION bool Restrict editor selection (Selection objects).
    DOCUMENT_INFO_DATECREATED long Creation date.
    DOCUMENT_INFO_PRGCREATOR_NAME str Name of the creation software.
    DOCUMENT_INFO_PRGCREATOR_ID int ID of the creation software.
      MAXON_CREATOR_ID MAXON.
    DOCUMENT_MULTISELECTIONHIGHLIGHT BaseLink Private.
    DOCUMENT_INFO_AUTHOR str Document author.
    DOCUMENT_INFO_COPYRIGHT str Copyright info.
    DOCUMENT_INFO_README str Info string.
    DOCUMENT_INFO_DATESAVED long Last save date.
    DOCUMENT_INFO_PRGWRITER_NAME str Software the document was saved last.
    DOCUMENT_INFO_PRGWRITER_ID int ID of the software the document was saved last.
      MAXON_CREATOR_ID MAXON.
    • DOCUMENTSETTINGS_ANIMATIONSYSTEM
    Time line settings. (Private!)
    • DOCUMENTSETTINGS_TOOLS
    Tools settings. (Unused)
  • bc (BaseContainer) – The container to take the new settings from.
BaseDocument.GetSettingsInstance(type)

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:

  • DOCUMENTSETTINGS_GENERAL
General settings.
DOCUMENT_TIME BaseTime Current document time.
DOCUMENT_FPS int Frame rate (frames per second).
DOCUMENT_MINTIME BaseTime Start time.
DOCUMENT_MAXTIME BaseTime End time.
DOCUMENT_LOOPMINTIME BaseTime Start preview (loop) time.
DOCUMENT_LOOPMAXTIME BaseTime End preview (loop) time.
DOCUMENT_LOD float Level of detail (0-100%).
DOCUMENT_RENDERLOD bool Render LOD in editor.
DOCUMENT_USEANIMATION bool Use animation.
DOCUMENT_USEEXPRESSIONS bool Use expressions.
DOCUMENT_USEGENERATORS bool Use generators.
DOCUMENT_USEDEFORMERS bool Use deformers.
DOCUMENT_MODE bool Editor mode.
  Mcamera Camera mode.
  Mobject Object mode.
  Mtexture Texture mode.
  Mtextureaxis Texture axis mode.
  Mpoints Point edit mode.
  Medges Edge edit mode.
  Mpolygons Polygon edit mode.
  Manimation Animation mode.
  Mkinematic IK mode.
  Mmodel Model mode.
  Mpaint Paint mode.
  Muvpoints UV points.
  Muvpolygons UV polygons.
  Mdrag Drag mode.
  Mpolyedgepoint Combined poly/edge/point mode. Must only be used in ViewportSelect.
  Medgepoint Combined edge/point mode. Must only be used in ViewportSelect.
DOCUMENT_ACTION int ID of the current tool.
DOCUMENT_USERCHANGE bool Private.
DOCUMENT_PATH str Document file path.
DOCUMENT_NAME str Name of the document.
DOCUMENT_STATEX bool Lock/unlock X-axis.
DOCUMENT_STATEY bool Lock/unlock Y-axis.
DOCUMENT_STATEZ bool Lock/unlock Z-axis.
DOCUMENT_STATEW bool Use world/object coordinate system.
  • DOCUMENTSETTINGS_MODELING
Modeler settings.
See MDATA_Options and toolsnapping.h
  • DOCUMENTSETTINGS_DOCUMENT
Document settings.
DOCUMENT_COLORPROFILE int Input color profile.
  DOCUMENT_COLORPROFILE_SRGB sRGB.
  DOCUMENT_COLORPROFILE_LINEAR Linear.
  DOCUMENT_COLORPROFILE_DISABLED Disabled.
DOCUMENT_LINEARWORKFLOW bool Use linear workflow.
DOCUMENT_DOCUNIT UnitScaleData Document scale.
DOCUMENT_DEFAULTMATERIAL_TYPE int Default object color preset.
  DOCUMENT_DEFAULTMATERIAL_TYPE_WHITE 80% Gray.
  DOCUMENT_DEFAULTMATERIAL_TYPE_BLUE Gray-Blue.
  DOCUMENT_DEFAULTMATERIAL_TYPE_USER Custom.
DOCUMENT_DEFAULTMATERIAL_COLOR Vector Default object color.
DOCUMENT_CLIPPING_PRESET int View clipping preset.
  DOCUMENT_CLIPPING_PRESET_TINY Tiny.
  DOCUMENT_CLIPPING_PRESET_SMALL Small.
  DOCUMENT_CLIPPING_PRESET_MEDIUM Medium.
  DOCUMENT_CLIPPING_PRESET_LARGE Large.
  DOCUMENT_CLIPPING_PRESET_HUGE Huge.
  DOCUMENT_CLIPPING_PRESET_CUSTOM Custom.
DOCUMENT_CLIPPING_PRESET_NEAR float Near view clipping.
DOCUMENT_CLIPPING_PRESET_FAR float Far view clipping.
DOCUMENT_SELECTIONFILTER int Selection filter bit mask.
  SELECTIONFILTERBIT_0 None.
  SELECTIONFILTERBIT_NULL Null.
  SELECTIONFILTERBIT_POLYGON Polygon.
  SELECTIONFILTERBIT_SPLINE Spline.
  SELECTIONFILTERBIT_GENERATOR Generator.
  SELECTIONFILTERBIT_HYPERNURBS HyperNURBS.
  SELECTIONFILTERBIT_DEFORMER Deformer.
  SELECTIONFILTERBIT_CAMERA Camera.
  SELECTIONFILTERBIT_LIGHT Light.
  SELECTIONFILTERBIT_SCENE Scene.
  SELECTIONFILTERBIT_PARTICLE Particle.
  SELECTIONFILTERBIT_OTHER Other.
  SELECTIONFILTERBIT_JOINT Joint.
DOCUMENT_RESTRICTEDITORSELECTION bool Restrict editor selection (Selection objects).
DOCUMENT_INFO_DATECREATED long Creation date.
DOCUMENT_INFO_PRGCREATOR_NAME str Name of the creation software.
DOCUMENT_INFO_PRGCREATOR_ID int ID of the creation software.
  MAXON_CREATOR_ID MAXON.
DOCUMENT_MULTISELECTIONHIGHLIGHT BaseLink Private.
DOCUMENT_INFO_AUTHOR str Document author.
DOCUMENT_INFO_COPYRIGHT str Copyright info.
DOCUMENT_INFO_README str Info string.
DOCUMENT_INFO_DATESAVED long Last save date.
DOCUMENT_INFO_PRGWRITER_NAME str Software the document was saved last.
DOCUMENT_INFO_PRGWRITER_ID int ID of the software the document was saved last.
  MAXON_CREATOR_ID MAXON.
  • DOCUMENTSETTINGS_ANIMATIONSYSTEM
Time line settings. (Private!)
  • DOCUMENTSETTINGS_TOOLS
Tools settings. (Unused)
Return type: BaseContainer

:return. The settings container.

BaseDocument.GetFirstObject()

Returns the first object.

Return type: BaseObject
Returns: The first object, or None if no objects are contained in this document.
BaseDocument.GetFirstMaterial()

Returns the first material.

Return type: BaseMaterial
Returns: The active material, or None.
BaseDocument.GetActiveMaterials()

Returns the material selection.

Return type: list of type BaseMaterial
Returns: The selected materials in a list.
BaseDocument.GetOrderedActiveObjects()

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.
BaseDocument.GetActiveObjects(flags)

Returns the object selection.

Parameters: flags (int) –

Changed in version R13.051: Replaced argument children by flags, downward compatible.

Flags:

GETACTIVEOBJECTFLAGS_0 None.
GETACTIVEOBJECTFLAGS_CHILDREN Child objects are added to the selection too, provided they are selected. Otherwise only the topmost parent of each chain is added.
GETACTIVEOBJECTFLAGS_SELECTIONORDER The selection array is sorted in the selection order, e.g. the first selected object is the first element in the array.
Return type: list of type BaseList2D
Returns: The selected objects in a list.
BaseDocument.GetActiveTags()

Returns the tag selection.

Return type: list of type BaseTag
Returns: The selected tags in a list.
BaseDocument.GetSelection()

Returns the selection of materials, tags and objects in a list.

Return type: list of type BaseList2D
Returns: The selected objects in a list.
BaseDocument.GetActiveObjectsFilter(children, type, instanceof)

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:
  • children (bool) – If True then children are also added to selection, provided that they are selected. Otherwise only the topmost parent in each chain is added.
  • type (int) – Checked against C4DAtom.GetType(). Pass NOTOK to ignore this test.
  • instanceof (int) – Checked against C4DAtom.IsInstanceOf(). Pass NOTOK to ignore this test.
Return type:

list of type BaseList2D

Returns:

The selected objects in a list.

BaseDocument.GetObjects()

Returns the highest objects without children.

Return type: list of type BaseObject
Returns: The objects.
BaseDocument.SetSelection(bl[, mode=SELECTION_NEW])

Sets the active selection. This function deals with both objects, tags and materials.

Parameters:
  • bl (BaseList2D) – The baselist object within this document that you want to make active. Must be in the document already.
  • mode (int) –

    The selection mode:

    SELECTION_NEW Starts a new selection.
    SELECTION_ADD Adds to the current selection
    SELECTION_SUB Subtracts from the current selection.
BaseDocument.SearchMaterial(name)

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.
BaseDocument.SearchMaterialInc(name)

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.
BaseDocument.SearchObject(name)

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.
BaseDocument.SearchObjectInc(name)

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.
BaseDocument.GetHighest(type, editor)

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:
  • type (int) – the object type
  • editor (bool) – True will search using the ‘editor dot’ in the Object Manager, False will use the ‘render dot’.
Return type:

BaseObject

Returns:

The first requested object or None if nothing was found.

BaseDocument.InsertObject(op[, parent=None, pred=None, checknames=False])

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:
  • op (BaseObject) – Object to insert into the document.
  • parent (BaseObject) – Optional parent to insert the object as a child of.
  • pred (BaseObject) – Optional insertion point.
  • checknames (bool) – Check for duplicate names and append .1, .2 etc.
BaseDocument.InsertMaterial(op[, pred=None, checknames=None])

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:
  • op (BaseMaterial) – Material to insert into the document.
  • pred (BaseObject) – Optional insertion point for the material. Require condition pred.GetDocument()==op.GetDocument()==op. That means, the object has to be in the same document.
  • checknames (bool) – Check for duplicate names and append .1, .2 etc.
BaseDocument.GetHelperAxis()

The helper axis for the current multi selection.

Return type: BaseObject
Returns: The axis object.
BaseDocument.GetChanged()

Returns True if the document has been changed since it was last saved.

Return type: bool
Returns: True if the document has been changed.
BaseDocument.SetChanged()

Set changed state of the document to reflect it has been modified.

Document Caching

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()

Table Of Contents