c4d.documents
¶
Follow me to the Inheritance diagramm .
BaseVideoPost
NEW
IsolateObjects()
InteractiveModeling_Restart()
RunAnimation()
StopExternalRenderer()
GetBatchRender()
GetAllAssets()
SaveProject()
Assemble()
c4d.documents.
GetActiveDocument
(
)
¶
Returns the active document of Cinema 4D.
Return type: | c4d.documents.BaseDocument |
---|---|
Returns: | The actve document. |
c4d.documents.
GetFirstDocument
(
)
¶
Returns the first document in the list of documents within Cinema 4D.
Return type: | c4d.documents.BaseDocument |
---|---|
Returns: | The first document. |
c4d.documents.
SetActiveDocument
(
doc
)
¶
Sets doc as active document in Cinema 4D.
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: |
|
||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
bool |
||||||||||||||||||||||||||||||||
Returns: |
True if successful, otherwise False . |
c4d.documents.
RenderDocument
(
doc
,
rdata
,
bmp
[
,
renderflags=0
,
th=None
]
)
¶
Renders the document to a bitmap. You need to initialize the image with the size of the render data:
import c4d from c4d import bitmaps, documents doc = documents.GetActiveDocument() rd = doc.GetActiveRenderData().GetData() xres = int(rd[c4d.RDATA_XRES]) yres = int(rd[c4d.RDATA_YRES]) bmp = bitmaps.BaseBitmap() #Initialize the bitmap with the result size #The resolution must match with the output size of the render settings bmp.Init(x=xres, y=yres, depth=24) res = documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL) if res==c4d.RENDERRESULT_OK: bitmaps.ShowBitmap(bmp)
A
MultipassBitmap
must be passed to render the image with an alpha channel:
import c4d from c4d import bitmaps, documents doc = documents.GetActiveDocument() rd = doc.GetActiveRenderData().GetData() xres = int(rd[c4d.RDATA_XRES]) yres = int(rd[c4d.RDATA_YRES]) bmp = bitmaps.MultipassBitmap(xres, yres, c4d.COLORMODE_RGB) bmp.AddChannel(True, True) res = documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL) if res==c4d.RENDERRESULT_OK: bitmaps.ShowBitmap(bmp)
Parameters: |
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
int |
||||||||||||||||||
Returns: |
The result:
|
c4d.documents.
MergeDocument
(
doc
,
name
,
loadflags
[
,
thread
]
)
¶
Merges the file name into the document doc .
Parameters: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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, a C.O.F.F.E.E. script 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.
Parameters: | doc ( c4d.documents.BaseDocument ) – The document to insert. |
---|
c4d.documents.
LoadDocument
(
name
,
loadflags
[
,
thread
]
)
¶
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: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: | |||||||||||||||||
Returns: |
The document that was loaded, or None if it failed. |
c4d.documents.
CloseAllDocuments
(
)
¶
Closes all open documents in Cinema 4D.
Return type: | bool |
---|---|
Returns: | True on success, otherwise False |
c4d.documents.
SetDocumentTime
(
doc
,
time
)
¶
Controls the time of the active document doc. Unlike
BaseDocument.SetTime()
it handles running animation.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
True on success, otherwise False |
c4d.documents.
RunAnimation
(
doc
,
stop
[
,
forward
]
)
¶
Controls the animation in the active document doc .
Parameters: |
|
---|---|
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:
from c4d import documents, plugins class TestTool(plugins.ToolData): def MouseInput(self, doc, data, draw, win, msg): if not doc: return False if doc.GetMode() == documents.Medges: active = p.GetActiveObjects(True) #undo step before documents.InteractiveModeling_Restart(doc) self.ModelingEdgeCut(active, c4d.MODIFY_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). All materials associated are also copied over and the links are corrected.
Parameters: |
|
---|---|
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: | c4d.documents.BatchRender |
---|---|
Returns: | The batch render. |
c4d.documents.
GetAllAssets
(
doc
,
allowDialogs
,
lastPath
)
¶
New in version R15.057.
Get all assets from a document. It is e.g. used by
“Save Project with Assets”
menu and
SaveProject()
.
Parameters: |
|
---|
Return type: | list of dict{ filename : str, assetname : str, channelId : int, netRequestOnDemand : bool} |
---|---|
Returns: | The assets in the document doc or None if there was an error. |
c4d.documents.
SaveProject
(
doc, flags, targetPath[, assets][, missingAssets]
)
¶
New in version R15.057.
Save the document as a project (menu “Save Project with Assets” ).
Parameters: |
|
||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Return type: |
bool |
||||||||||||||||||||||
Returns: |
True if the document was successfully saved as a project, otherwise False . |
c4d.documents.
Assemble
(
inputpath
,
inputname
,
rdata
,
context
,
assembleRegular
,
assembleMultipass
,
bt
,
ifrom
,
ito
,
errorstring
,
clearimages
)
¶
New in version R16.050.
Private.
c4d.documents.
GetFirstMarker
(
doc
)
¶
Returns the first timeline marker of the document.
Parameters: | doc ( c4d.documents.BaseDocument ) – The document. |
---|---|
Return type: | c4d.BaseList2D |
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: |
|
---|---|
Return type: | |
Returns: |
The added timeline marker, or None if insertion failed. |