Repository navigation
Expand file tree
/
Copy pathreduction_preprocess.py
More file actions
55 lines (41 loc) · 1.55 KB
/
Copy pathreduction_preprocess.py
File metadata and controls
55 lines (41 loc) · 1.55 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
52
53
54
55
"""Configures the given PolygonReduction object. Reduces the given PolygonObject to 25%.
Topics:
* c4d.utils.PolygonReduction
"""
__author__ = "Yannick Puech"
__copyright__ = "Copyright (C) 2026 MAXON Computer GmbH"
__license__ = "Apache-2.0 License"
__version__ = "R19"
import c4d
def main():
# Checks if selected object is valid
if op is None:
raise ValueError("op is none, please select one object.")
# Check if it's a polygon object
if not op.IsInstanceOf(c4d.Opolygon):
raise TypeError("Selected object is not a polygon Object.")
# Defines settings for PolygonReduction.PreProcess()
settings = c4d.BaseContainer()
settings[c4d.POLYREDUXOBJECT_PRESERVE_3D_BOUNDARY] = True
settings[c4d.POLYREDUXOBJECT_PRESERVE_UV_BOUNDARY] = True
# Defines data for PolygonReduction.PreProcess()
data = dict()
data['_op'] = op
data['_doc'] = doc
data['_settings'] = settings
data['_thread'] = None
# Creates PolygonReduction object
polyReduction = c4d.utils.PolygonReduction()
if polyReduction is None:
raise RuntimeError("Failed to create the PolygonReduction.")
# Pre-process the data
if not polyReduction.PreProcess(data):
raise RuntimeError("Failed to Pre-Process the PolygonReduction with data.")
# Runs the reduce process of the polygon object
polyReduction.SetReductionStrengthLevel(0.75)
# Updates original PolygonObject
op.Message(c4d.MSG_UPDATE)
# Pushes an update event to Cinema 4D
c4d.EventAdd()
if __name__ == '__main__':
main()