Types¶
Functions Signatures
Retrieves the recent documents list. |
|
Returns the active document of Cinema 4D. |
|
Returns the first document in the list of documents within Cinema 4D. |
|
Sets doc in the editor that the user is editing, this is the active document. |
|
Saves the document to a file. |
|
Renders the document to a bitmap. You need to initialize the image with the size of the render data |
|
Merges the file name into the document doc. |
|
Loads a file into Cinema 4D and opens it. |
|
Removes and free all resources of this document. |
|
Inserts a document into the Cinema 4D editor list of documents. |
|
Similar to |
|
Closes all open documents in Cinema 4D. |
|
Controls the time of the active document doc. |
|
Controls the animation in the active document doc. |
|
Used for modeling tools with GUI input.
|
|
A helper routine to copy the objects t_objects of document doc to a new document (returned). |
|
Stop the external renderer. |
|
Get the batch render instance. |
|
Deprecated since version S22: Use |
|
Get all assets from a document.
|
|
Save the document as a project (menu “Save Project with Assets”). |
|
Returns the first timeline marker of the document. |
|
Inserts a timeline marker into the document at a given time. Optionally an insertion point pPred in the timeline marker list can be specified, giving the marker before the wanted insertion point. |
Functions Documentation
-
c4d.documents.
GetRecentDocumentsList
(isBodyPaint=False)¶ Retrieves the recent documents list.
New in version R21.
- Parameters
isBodyPaint (bool) – True to retrieve BodyPaint’s list.
- Return type
- Returns
The recent documents list.
-
c4d.documents.
GetActiveDocument
()¶ Returns the active document of Cinema 4D.
- Return type
- Returns
The active document.
-
c4d.documents.
GetFirstDocument
()¶ Returns the first document in the list of documents within Cinema 4D.
- Return type
- Returns
The first document.
-
c4d.documents.
SetActiveDocument
(doc)¶ Sets doc in the editor that the user is editing, this is the active document.
Warning
It’s mandatory for doc to be already inserted into the Cinema 4D list of documents.This can be done withInsertBaseDocument()
.- Parameters
doc (c4d.documents.BaseDocument) – The document.
-
c4d.documents.
SaveDocument
(doc, name, saveflags, format)¶ Saves the document to a file.
See also
The script that shows how to effectively access and change the settings of an importer/exporter.
See also
Warning note in
SceneSaverData.Save()
.- Parameters
doc (c4d.documents.BaseDocument) – Command ID
name (Union[str, c4d.storage.MemoryFileStruct]) – File to save the document to.
saveflags (int) –
The flags
SAVEDOCUMENTFLAGS_NONE
None.
SAVEDOCUMENTFLAGS_DIALOGSALLOWED
Flag to inform that a dialog can be displayed. If this flag is not set then no dialogs must be opened.
SAVEDOCUMENTFLAGS_SAVEAS
Forces a “Save As” and opens the file dialog.
SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST
Do not add the saved document to the recent file list.
SAVEDOCUMENTFLAGS_AUTOSAVE
Sets the “Auto Save” mode. Files are not added to the recent file list and the document change star will not be reset.
SAVEDOCUMENTFLAGS_SAVECACHES
For melange export only. Caches of objects will also be written (only supported by Cinema 4D file format).
SAVEDOCUMENTFLAGS_EXPORTDIALOG
Opens the Export dialog.
SAVEDOCUMENTFLAGS_CRASHSITUATION
This flag is passed to Cinema 4D if a crash occurred.
SAVEDOCUMENTFLAGS_NO_SHADERCACHE
Disables the SCENEFILTER_SAVE_BINARYCACHE flag.
format (int) –
The file format to save the document as.
FORMAT_PREF
Preferences.
FORMAT_WAV
WAV sound.
FORMAT_L4D
Layout.
FORMAT_P4D
Layout.
FORMAT_C4DIMPORT
Cinema 4D import.
FORMAT_C4DEXPORT
Cinema 4D export.
FORMAT_VRML1IMPORT
VRML 1 import.
FORMAT_VRML1EXPORT
VRML 1 export.
FORMAT_VRML2IMPORT
VRML 2 import.
FORMAT_VRML2EXPORT
VRML 2 export.
FORMAT_DXFIMPORT
DXF import.
FORMAT_DXFEXPORT
DXF export.
FORMAT_3DSIMPORT
3DS import.
FORMAT_3DSEXPORT
3DS export.
FORMAT_OBJIMPORT
Old OBJ import (R16 and older).
FORMAT_OBJEXPORT
Old OBJ export (R16 and older).
FORMAT_Q3DIMPORT
QuickDraw 3D import.
FORMAT_Q3DEXPORT
QuickDraw 3D export.
FORMAT_AIIMPORT
AI import.
FORMAT_DEMIMPORT
DEM import.
FORMAT_D3DEXPORT
Direct3D export.
FORMAT_OBJ2IMPORT
New in version R17.048: New OBJ import (R17 and newer).
FORMAT_OBJ2EXPORT
New in version R17.048: New OBJ export (R17 and newer).
FORMAT_SKPIMPORT
New in version R17.048: SketchUp import.
FORMAT_STEPIMPORT
New in version R20.026: Step import.
FORMAT_CATIAIMPORT
New in version R20.026: Catia V5 import.
FORMAT_IGESIMPORT
New in version R20.026: Iges import.
FORMAT_JTIMPORT
New in version R20.026: Jt import.
FORMAT_SOLIDWORKSIMPORT
New in version R20.026: Solidworks import.
FORMAT_ABCIMPORT
New in version R20.041: Alembic import (R20.041 and newer).
FORMAT_ABCEXPORT
New in version R20.041: Alembic export (R20.041 and newer).
FORMAT_DAE14IMPORT
New in version R20.041: Collada 14 import (R20.041 and newer).
FORMAT_DAE14EXPORT
New in version R20.041: Collada 14 export (R20.041 and newer).
FORMAT_DAE15IMPORT
New in version R20.041: Collada 15 import (R20.041 and newer).
FORMAT_DAE15EXPORT
New in version R20.041: Collada 15 export (R20.041 and newer).
FORMAT_AI_EXPORT
New in version S22: Adobe Illustrator AI export.
FORMAT_ALLPLAN_EXPORT
New in version S22: Allplan XML export.
FORMAT_BVH_IMPORT
New in version S22: BVH import.
FORMAT_FBX_EXPORT
New in version S22: FBX export.
FORMAT_FBX_IMPORT
New in version S22: FBX import.
FORMAT_GLTFEXPORT
New in version S22: glTF export.
FORMAT_DWG_IMPORT
New in version S22: AutoCAD DWG import.
FORMAT_STL_EXPORT
New in version S22: STL export.
FORMAT_STL_IMPORT
New in version S22: STL import.
FORMAT_VDB_EXPORT
New in version S22: Volume VDB export.
FORMAT_VDB_IMPORT
New in version S22: Volume VDB import.
- Return type
bool
- Returns
True if successful, otherwise False.
-
c4d.documents.
RenderDocument
(doc, rdata, bmp, renderflags=0, th=None, prog=None, wprog=None)¶ Renders the document to a bitmap. You need to initialize the image with the size of the render data
Note
A
MultipassBitmap
must be passed to render the image with an alpha channel.""" Copyright: MAXON Computer GmbH Author: Maxime Adam Description: - Render the current document with a progress hook to get notified about the current rendering progress. Class/method highlighted: - c4d.bitmaps.MultipassBitmap - c4d.documents.RenderDocument() """ import c4d def PythonCallBack(progress, progress_type): """Function passed in RenderDocument. It will be called automatically by Cinema 4D with the current render progress. Args: progress (float): The percent of the progress for the current step progress_type (c4d.RENDERPROGRESSTYPE): The Main part of the current rendering step """ text = str() if progress_type == c4d.RENDERPROGRESSTYPE_BEFORERENDERING: text = "Before Rendering" elif progress_type == c4d.RENDERPROGRESSTYPE_DURINGRENDERING: text = "During Rendering" elif progress_type == c4d.RENDERPROGRESSTYPE_AFTERRENDERING: text = "After Rendering" elif progress_type == c4d.RENDERPROGRESSTYPE_GLOBALILLUMINATION: text = "GI" elif progress_type == c4d.RENDERPROGRESSTYPE_QUICK_PREVIEW: text = "Quick Preview" elif progress_type == c4d.RENDERPROGRESSTYPE_AMBIENTOCCLUSION: text = "AO" # Prints to the console the current progress print("ProgressHook called [{0} / p: {1}]".format(text, progress * 100.0)) def PythonWriteCallBack(mode, bmp, fn, mainImage, frame, renderTime, streamnum, streamname): """Function passed in RenderDocument. It will be called automatically by Cinema 4D when the file rendered file should be saved. Args: mode (c4d.WRITEMODE): The write mode. bmp (c4d.bitmaps.BaseBitmap): The bitmap written to. fn (str): The path where the file should be saved. mainImage (bool): True for main image, otherwise False. frame (int): The frame number. renderTime (int): The bitmap frame time. streamnum (int): The stream number. streamname (streamname: str): The stream name. """ text = str() if mode == c4d.WRITEMODE_STANDARD: text = "Standard" elif mode == c4d.WRITEMODE_ASSEMBLE_MOVIE: text = "Assemble Movie" elif mode == c4d.WRITEMODE_ASSEMBLE_SINGLEIMAGE: text = "Assemble single image" print("ProgressWriteHook called [{0} / p: {1}]".format(text, renderTime)) def main(): # Retrieves the current active render settings rd = doc.GetActiveRenderData() # Creates a Multi Pass Bitmaps that will store the render result bmp = c4d.bitmaps.MultipassBitmap(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]), c4d.COLORMODE_RGB) if bmp is None: raise RuntimeError("Failed to create the bitmap.") # Adds an alpha channel bmp.AddChannel(True, True) # Renders the document if c4d.documents.RenderDocument(doc, rd.GetData(), bmp, c4d.RENDERFLAGS_EXTERNAL, prog=PythonCallBack, wprog=PythonWriteCallBack) != c4d.RENDERRESULT_OK: raise RuntimeError("Failed to render the temporary document.") # Displays the render in the Picture Viewer c4d.bitmaps.ShowBitmap(bmp) if __name__ == "__main__": main()
- Parameters
doc (c4d.documents.BaseDocument) – The document you want to render.
rdata (c4d.BaseContainer) – The render data.
bmp (c4d.bitmaps.BaseBitmap) – The bitmap where the rendered picture will be saved in. Initialize the image with the size of the render data.
renderflags (int) –
Some renderflags.
RENDERFLAGS_NONE
None.
RENDERFLAGS_EXTERNAL
External render.
RENDERFLAGS_NODOCUMENTCLONE
Set to avoid an automatic clone of the scene sent to
RenderDocument()
.RENDERFLAGS_SHOWERRORS
Show error messages.
RENDERFLAGS_PREVIEWRENDER
Preview render.
RENDERFLAGS_IRR
Interactive region render.
RENDERFLAGS_CREATE_PICTUREVIEWER
Render in a new Picture Viewer.
RENDERFLAGS_OPEN_PICTUREVIEWER
Open the Picture Viewer.
RENDERFLAGS_KEEP_CONTEXT
Private.
RENDERFLAGS_BATCHRENDER
Render in Batch Render. Private.
RENDERFLAGS_NET
Use NET System for rendering.
RENDERFLAGS_DONTANIMATE
New in version R17.032: Do not animate document before rendering. This should only be used in combination with RENDERFLAGS_PREVIEWRENDER.
RENDERFLAGS_PREVIEWSETTINGS
New in version R19: Use preview settings.
RENDERFLAGS_RENDERQUEUEERRORS
New in version R21.108: Cancel Render Queue rendering if scene has missing assets.
Note
If you are in a safe context you might use RENDERFLAG_NODOCUMENTCLONE to speed up the render process especially on big scenes.
th (Optional[c4d.threading.BaseThread]) – The thread to test for a break or None.
prog (Optional[Callable[[float, int], None]]) –
New in version R21.
A function that will be called during the rendering with information about the current progress.
The expected function signature is functionName(p, progress_type) and parameters correspond to:
p (float): The progress, between 0.0 and 1.0.
progress_type: The render Progress type:
New in version R21.
Symbol ID
Description
RENDERPROGRESSTYPE_BEFORERENDERING
Before rendering.
RENDERPROGRESSTYPE_DURINGRENDERING
During rendering.
RENDERPROGRESSTYPE_AFTERRENDERING
After rendering.
RENDERPROGRESSTYPE_GLOBALILLUMINATION
GI prepass.
RENDERPROGRESSTYPE_QUICK_PREVIEW
Quick Preview rendering.
RENDERPROGRESSTYPE_AMBIENTOCCLUSION
AO prepass.
wprog (Optional[Callable[[int, Optional[c4d.bitmaps.BaseBitmap], str, bool, int, int, int, str], None]]) –
New in version R21.
The write progress hook for the render operation.
The expected function signature is functionName(mode, bmp, fn, mainImage, frame, renderTime, streamnum, streamname) and parameters correspond to:
mode: the write mode type:
Symbol ID
Description
WRITEMODE_STANDARD
Standard.
WRITEMODE_ASSEMBLE_MOVIE
Assemble movie.
WRITEMODE_ASSEMBLE_SINGLEIMAGE
Assemble single image.
bmp (
c4d.bitmaps.BaseBitmap
): The bitmap written to. Can be None.fn (str): The filename where the file is going to be written to.
mainImage (bool): True for main image, otherwise False.
frame (int): The frame number.
renderTime (int): The bitmap frame time.
streamnum (int): The stream number.
streamname (str): The stream name.
- Return type
int
- Returns
The result:
RENDERRESULT_OUTOFMEMORY Not enough memory. RENDERRESULT_ASSETMISSING Assets (textures etc.) are missing. RENDERRESULT_SAVINGFAILED Failed to save. RENDERRESULT_USERBREAK User stopped the processing. RENDERRESULT_GICACHEMISSING GI cache is missing. RENDERRESULT_NOMACHINE Machine was not found. Can only happen during Team Rendering. RENDERRESULT_PROJECTNOTFOUND Project was not found. Can only be returned by Cinema 4D during command line rendering. RENDERRESULT_ERRORLOADINGPROJECT There was an error while loading the project. Can only be returned by Cinema 4D during command line rendering. RENDERRESULT_NOOUTPUTSPECIFIED Output was not specified. Can only be returned by Cinema 4D during command line rendering. ================================== ==============================================================================================================
-
c4d.documents.
MergeDocument
(doc, name, loadflags, thread)¶ Merges the file name into the document doc.
- Parameters
doc (c4d.documents.BaseDocument) – The document to merge the loaded document name into.
name (Union[str, c4d.storage.MemoryFileStruct]) – The file to merge into doc.
loadflags (int) –
The scene filter flags for the loader:
SCENEFILTER_NONE
None.
SCENEFILTER_OBJECTS
Load/save objects.
SCENEFILTER_MATERIALS
Load/save materials.
SCENEFILTER_DIALOGSALLOWED
Flag to inform a plugin that a dialog can be displayed. If this flag is not set then no dialogs must be opened.
SCENEFILTER_PROGRESSALLOWED
Flag to inform a plugin that a progress bar can be displayed. The progress bar can be set by calling
StatusSetBar()
.SCENEFILTER_MERGESCENE
Flag to inform a plugin that this is a merge operation, i.e. the document that is inserted to is an existing scene.
SCENEFILTER_NONEWMARKERS
Objects loaded from disk will keep their markers.
SCENEFILTER_SAVECACHES
For melange export only. Caches of objects will also be written (only supported by Cinema 4D format). This is the same as the global option “Save Polygon Objects for Melange Exchange”.
SCENEFILTER_NOUNDO
Use together with SCENEFILTER_MERGESCENE to avoid that undos are created for the merge operation.
SCENEFILTER_SAVE_BINARYCACHE
Save the binary compiled shaders with the scene (only for Cinema 4D format).
SCENEFILTER_IDENTIFY_ONLY
Do not load the whole document, identify it only.
SCENEFILTER_ONLY_RENDERDATA
Only load render settings. If this flag is set, SCENEFILTER_OBJECTS and SCENEFILTER_MATERIALS are ignored.
SCENEFILTER_IGNOREMISSINGPLUGINSINNONACTIVERENDERDATA
Ignore all missing plugins which are part of a non-active render data.
SCENEFILTER_IGNOREXREFS
New in version R16.038: Avoid that included X-Refs will be loaded.
SCENEFILTER_DONTCORRECTOUTPUTFORMAT
Do not change unknown output formats in render settings.
thread (Optional[c4d.threading.BaseThread]) – The current thread, or None for the main Cinema 4D thread.
- Return type
bool
- Returns
True if successful, otherwise False.
-
c4d.documents.
LoadFile
(name)¶ Loads a file into Cinema 4D and opens it.
Note
This function can be used to open any kind of file Cinema 4D handles i.e. a document, an image, a layout or a lib4d/cat4d file.
- Parameters
name (str) – The file to load.
-
c4d.documents.
KillDocument
(doc)¶ Removes and free all resources of this document.
- Parameters
doc (c4d.documents.BaseDocument) – The document to free.
-
c4d.documents.
InsertBaseDocument
(doc)¶ Inserts a document into the Cinema 4D editor list of documents.
Note
SetActiveDocument()
is called implicitly.- Parameters
doc (c4d.documents.BaseDocument) – The document to insert.
-
c4d.documents.
LoadDocument
(name, loadflags, thread=None)¶ Similar to
LoadFile()
but this time the document is not put into the editors list of documents and it gives control over the loaded document.- Parameters
name (Union[str, c4d.storage.MemoryFileStruct]) – The name of the file to load the document from.
loadflags (int) –
The scene filter flags for the loader:
SCENEFILTER_NONE
None.
SCENEFILTER_OBJECTS
Load/save objects.
SCENEFILTER_MATERIALS
Load/save materials.
SCENEFILTER_DIALOGSALLOWED
Flag to inform a plugin that a dialog can be displayed. If this flag is not set then no dialogs must be opened.
SCENEFILTER_PROGRESSALLOWED
Flag to inform a plugin that a progress bar can be displayed. The progress bar can be set by calling
StatusSetBar()
.SCENEFILTER_MERGESCENE
Flag to inform a plugin that this is a merge operation, i.e. the document that is inserted to is an existing scene.
SCENEFILTER_NONEWMARKERS
Objects loaded from disk will keep their markers.
SCENEFILTER_SAVECACHES
For melange export only. Caches of objects will also be written (only supported by Cinema 4D format). This is the same as the global option “Save Polygon Objects for Melange Exchange”.
SCENEFILTER_NOUNDO
Use together with SCENEFILTER_MERGESCENE to avoid that undos are created for the merge operation.
SCENEFILTER_SAVE_BINARYCACHE
Save the binary compiled shaders with the scene (only for Cinema 4D format).
SCENEFILTER_IDENTIFY_ONLY
Do not load the whole document, identify it only.
SCENEFILTER_ONLY_RENDERDATA
Only load render settings. If this flag is set, SCENEFILTER_OBJECTS and SCENEFILTER_MATERIALS are ignored.
SCENEFILTER_IGNOREMISSINGPLUGINSINNONACTIVERENDERDATA
Ignore all missing plugins which are part of a non-active render data.
SCENEFILTER_IGNOREXREFS
New in version R16.038: Avoid that included X-Refs will be loaded.
SCENEFILTER_DONTCORRECTOUTPUTFORMAT
Do not change unknown output formats in render settings.
thread (Optional[c4d.threading.BaseThread]) – The current thread, or None for the main Cinema 4D thread.
- Return type
Optional[c4d.documents.BaseDocument]
- Returns
The document that was loaded, or None if it failed.
-
c4d.documents.
CloseAllDocuments
()¶ Closes all open documents in Cinema 4D.
-
c4d.documents.
SetDocumentTime
(doc, time)¶ Controls the time of the active document doc.
Note
Unlike
BaseDocument.SetTime()
it handles running animation.- Parameters
doc (c4d.documents.BaseDocument) – The document to control.
time (c4d.BaseTime) – The time to set.
- Return type
bool
- Returns
True on success, otherwise False
-
c4d.documents.
RunAnimation
(doc, stop, forward)¶ Controls the animation in the active document doc.
- Parameters
doc (c4d.documents.BaseDocument) – The document to control. Usually
GetActiveDocument()
stop (bool) – If this is True the animation is stopped, otherwise it is running.
forward (bool) – If this is True the direction is set to forward, otherwise it is set to backward.
- Return type
bool
- Returns
True on success, otherwise False
-
c4d.documents.
InteractiveModeling_Restart
(doc)¶ - Used for modeling tools with GUI input.Applies the last modeling undo so that new values of the modeling tool can be applied.
An example from the edge cut code.
import c4d class TestTool(c4d.plugins.ToolData): def MouseInput(self, doc, data, draw, win, msg): if not doc: return False if doc.GetMode() == c4d.Medges: active = p.GetActiveObjects(True) # Undo step before c4d.documents.InteractiveModeling_Restart(doc) self.ModelingEdgeCut(active, c4d.MODELINGCOMMANDMODE_EDGESELECTION, data, doc, win, msg, True) c4d.EventAdd() return True
- Parameters
doc (c4d.documents.BaseDocument) – The document.
- Return type
bool
- Returns
True if successful, otherwise False.
-
c4d.documents.
IsolateObjects
(doc, t_objects)¶ A helper routine to copy the objects t_objects of document doc to a new document (returned).
Note
All materials associated are also copied over and the links are corrected.
- Parameters
doc (c4d.documents.BaseDocument) – The document that contains the objects in t_objects.
t_objects (List[c4d.BaseObject]) – The objects to isolate.
- Return type
- Returns
The document containing the isolated objects.
-
c4d.documents.
StopExternalRenderer
()¶ Stop the external renderer.
- Return type
bool
- Returns
True if the rendering has been canceled, otherwise False.
-
c4d.documents.
GetBatchRender
()¶ Get the batch render instance.
- Return type
- Returns
The batch render.
-
c4d.documents.
GetAllAssets
(doc, allowDialogs, lastPath, flags=ASSETDATA_FLAG_NONE)¶ Deprecated since version S22: Use
c4d.documents.GetAllAssetsNew()
.Get all assets from a document.It is e.g. used by “Save Project with Assets” menu andSaveProject()
.New in version R15.057.
- Parameters
doc (c4d.documents.BaseDocument) – The document to save as project.
allowDialogs (bool) – If True the function can open dialogs. For example a file select dialog is opened if a node of the scene points to a file which does not exist anymore.
lastPath (str) –
Pass an empty string, that will be filled with the last path used.If a file dialog is opened and the user selects the missing file on the harddisk, the folder of this asset is assigned to lastPath.The developer can store this value somewhere and pass it next time so Cinema 4D knows where to look first before asking the user again.flags (int) –
New in version R20: The flags to decide which assets should be collected:
ASSETDATA_FLAG_NONE
None.
ASSETDATA_FLAG_CURRENTFRAMEONLY
Only return current frame assets.
ASSETDATA_FLAG_TEXTURESONLY
Only return texture assets. Since R17.048 (was ASSETDATA_FLAG_TEXTURES).
ASSETDATA_FLAG_NET
Set if NET is collecting assets to distribute them to the clients.
ASSETDATA_FLAG_CURRENTTAKEONLY
- Only return current take assets.
New in version R17.
ASSETDATA_FLAG_WITHCACHES
- Also return caches (Global Illumination / Ambient Occlusion).
New in version R17.048.
ASSETDATA_FLAG_NOSUBSTANCES
- Normally Substance assets are included with ASSETDATA_FLAG_TEXTURESONLY but with this flag they are not.
New in version R18.
ASSETDATA_FLAG_MULTIPLEUSE
- Adds the same asset again for every usage.
New in version R20.
ASSETDATA_FLAG_MISSING
- Only existing assets will be included.
New in version S22.
ASSETDATA_FLAG_NODOCUMENT
- Exclude the document itself from the asset list.
New in version R21.
- Return type
Optional[List[Dict]]
- Returns
The assets in the document, or None if there was an error.
The dictionary for each returned asset is:
filename: str: The asset filename.
assetname: str: The asset name.
channelId: int: The asset channel ID.
netRequestOnDemand: bool: NET request on demand.
owner:
c4d.BaseList2D
: The owner object. Since R20.exists: bool: Tells if the asset could be found. Since R20.
paramId: int: The parameter ID. Since R20.
nodePath: str: The node path of the port the asset is assigned to in case of a nimbus material. Since R20.
nodeSpace: str: The node space id in case of a nimbus material. Since R21.
-
c4d.documents.
GetAllAssetsNew
(doc, allowDialogs, lastPath, flags=ASSETDATA_FLAG_NONE, assetList=[])¶ - Get all assets from a document.It is e.g. used by “Save Project with Assets” menu and
SaveProject()
.New in version S22.
- Parameters
doc (c4d.documents.BaseDocument) – The document to get the assets from.
allowDialogs (bool) – If True the function can open dialogs. For example a file select dialog is opened if a node of the scene points to a file which does not exist anymore.
lastPath (str) –
Pass an empty string, that will be filled with the last path used.If a file dialog is opened and the user selects the missing file on the harddisk, the folder of this asset is assigned to lastPath.The developer can store this value somewhere and pass it next time so Cinema 4D knows where to look first before asking the user again.flags (int) –
The flags to decide which assets should be collected:
ASSETDATA_FLAG_NONE
None.
ASSETDATA_FLAG_CURRENTFRAMEONLY
Only return current frame assets.
ASSETDATA_FLAG_TEXTURESONLY
Only return texture assets. Since R17.048 (was ASSETDATA_FLAG_TEXTURES).
ASSETDATA_FLAG_NET
Set if NET is collecting assets to distribute them to the clients.
ASSETDATA_FLAG_CURRENTTAKEONLY
- Only return current take assets.
New in version R17.
ASSETDATA_FLAG_WITHCACHES
- Also return caches (Global Illumination / Ambient Occlusion).
New in version R17.048.
ASSETDATA_FLAG_NOSUBSTANCES
- Normally Substance assets are included with ASSETDATA_FLAG_TEXTURESONLY but with this flag they are not.
New in version R18.
ASSETDATA_FLAG_MULTIPLEUSE
- Adds the same asset again for every usage.
New in version R20.
ASSETDATA_FLAG_MISSING
- Only existing assets will be included.
New in version S22.
ASSETDATA_FLAG_NODOCUMENT
- Exclude the document itself from the asset list.
New in version R21.
assetList (List[Dict]) –
A list filled with assets in the document.
The dictionary for each returned asset is:
filename: str: The asset filename.
assetname: str: The asset name.
channelId: int: The asset channel ID.
netRequestOnDemand: bool: NET request on demand.
owner:
c4d.BaseList2D
: The owner object. Since R20.exists: bool: Tells if the asset could be found. Since R20.
paramId: int: The parameter ID. Since R20.
nodePath: str: The node path of the port the asset is assigned to in case of a nimbus material. Since R20.
nodeSpace: str: The node space id in case of a nimbus material. Since R21.
- Return type
int
- Returns
The success state.
New in version S22.
Symbol ID
Description
GETALLASSETSRESULT_FAILED
Function call went wrong.
GETALLASSETSRESULT_OK
Function succeeded and all assets exists.
GETALLASSETSRESULT_MISSING
Function succeeded but some assets cannot be found.
-
c4d.documents.
SaveProject
(doc, flags, targetPath, assets, missingAssets)¶ Save the document as a project (menu “Save Project with Assets”).
New in version R15.057.
- Parameters
doc (c4d.documents.BaseDocument) – The document to save as project.
flags (int) –
Flags:
SAVEPROJECT_NONE
None.
SAVEPROJECT_ASSETS
Pass if the assets will be taken into account.
SAVEPROJECT_SCENEFILE
Pass if the scene will be taken into account.
SAVEPROJECT_DIALOGSALLOWED
Show dialogs like error messages, a file selection for missing assets or alerts if necessary.
SAVEPROJECT_SHOWMISSINGASSETDIALOG
If an asset is missing show a warning dialog. Flag can be set without SAVEPROJECT_DIALOGSALLOWED.
SAVEPROJECT_ADDTORECENTLIST
Add document to the recent list.
SAVEPROJECT_DONTCOPYFILES
Does the same as without this flag but does not copy the files to the destination. Flag used to simulate the function.
SAVEPROJECT_PROGRESSALLOWED
Show the progress bar in the main window.
SAVEPROJECT_DONTTOUCHDOCUMENT
Document will be in the same state as before the call was made.
SAVEPROJECT_DONTFAILONMISSINGASSETS
If this flag is passed, the function does not fail anymore when assets are missing.
SAVEPROJECT_ISNET
Private. Set only if NET module is collecting assets.
SAVEPROJECT_USEDOCUMENTNAMEASFILENAME
Use the document name as the file name to save as project.
SAVEPROJECT_DONTCLEARSUGGESTEDFOLDER
Do not change asset paths of nodes.
SAVEPROJECT_WITHCACHES
New in version R17.048: Save the project assets with Global Illumination / Ambient Occlusion caches. See also ASSETDATA_FLAG_WITHCACHES.
SAVEPROJECT_DONTGENERATEPAINTTEX
New in version R17.053: Does the same as without this flag but does not generate the textures from painted materials.
SAVEPROJECT_ASSETLINKS_COPY_FILEASSETS
New in version S24: Copy file assets (assets://) to the tex folder.
SAVEPROJECT_ASSETLINKS_COPY_NODEASSETS
New in version S24: Copy node assets to the scene repository.
targetPath (str) – The path to save the project to.
assets (List[Dict[filename: str, assetname: str, channelId: int, netRequestOnDemand: bool]]) – Pass an empty list that will be filled with the found assets.
missingAssets (List[Dict[filename: str, assetname: str, channelId: int, netRequestOnDemand: bool]) – Pass an empty list that will be filled with the missing assets.
- Return type
bool
- Returns
True if the document was successfully saved as a project, otherwise False.
missingAssets = [] assets = [] targetPath = "some path" res = c4d.documents.SaveProject(doc, c4d.SAVEPROJECT_ASSETS | c4d.SAVEPROJECT_SCENEFILE, targetPath, assets, missingAssets)
-
c4d.documents.
GetFirstMarker
(doc)¶ Returns the first timeline marker of the document.
- Parameters
doc (c4d.documents.BaseDocument) – The document.
- Return type
- Returns
The first timeline marker.
-
c4d.documents.
AddMarker
(doc, pPred, time, name)¶ Inserts a timeline marker into the document at a given time. Optionally an insertion point pPred in the timeline marker list can be specified, giving the marker before the wanted insertion point.
- Parameters
doc (c4d.documents.BaseDocument) – The document in which to insert.
pPred (Optional[ c4d.BaseList2D]) – The optional timeline marker to use as list insertion point.
time (c4d.BaseTime) – The time position of the timeline marker.
name (str) – The name of the timeline marker.
- Return type
Optional[c4d.BaseList2D]
- Returns
The added timeline marker, or None if insertion failed.