Repository navigation
Expand file tree
/
Copy pathexport_alembic.py
More file actions
51 lines (39 loc) · 1.74 KB
/
Copy pathexport_alembic.py
File metadata and controls
51 lines (39 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Exports Alembic with custom settings.
Topics:
* c4d.plugins.FindPlugin()
* MSG_RETRIEVEPRIVATEDATA
* c4d.documents.SaveDocument()
"""
__author__ = "Ferdinand Hoppe"
__copyright__ = "Copyright (C) 2026 MAXON Computer GmbH"
__license__ = "Apache-2.0 License"
__version__ = "R14"
import c4d
def main():
# Retrieves a path to save the exported file
filePath = c4d.storage.LoadDialog(title="Save File for Alembic Export", flags=c4d.FILESELECT_SAVE, force_suffix="abc")
if not filePath:
return
# Retrieves Alembic exporter plugin, 1028082, defined in R20.046 as FORMAT_ABCEXPORT
abcExportId = 1028082 if c4d.GetC4DVersion() < 20046 else c4d.FORMAT_ABCEXPORT
plug = c4d.plugins.FindPlugin(abcExportId, c4d.PLUGINTYPE_SCENESAVER)
if plug is None:
raise RuntimeError("Failed to retrieve the alembic exporter.")
data = dict()
# Sends MSG_RETRIEVEPRIVATEDATA to Alembic export plugin
if not plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, data):
raise RuntimeError("Failed to retrieve private data.")
# BaseList2D object stored in "imexporter" key hold the settings
abcExport = data.get("imexporter", None)
if abcExport is None:
raise RuntimeError("Failed to retrieve BaseContainer private data.")
# Defines Alembic export settings
abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = True
abcExport[c4d.ABCEXPORT_PARTICLES] = False
abcExport[c4d.ABCEXPORT_PARTICLE_GEOMETRY] = False
# Finally export the document
if not c4d.documents.SaveDocument(doc, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, abcExportId):
raise RuntimeError("Failed to save the document.")
print("Document successfully exported to:", filePath)
if __name__ == '__main__':
main()