2323
2424QUARTER_PI = math .pi * .25
2525
26+
2627def ReadNormalTag (tag ):
2728 """Reads a c4d.NormalTag to a list of c4d.Vector.
2829
@@ -59,6 +60,7 @@ def ReadNormalTag(tag):
5960 data [i - 1 ] * factor )
6061 for i in range (3 , len (data ) + 3 , 3 )]
6162
63+
6264def WriteNormalTag (tag , normals , doNormalize = True ):
6365 """Writes a list of c4d.Vector to a c4d.NormalTag.
6466
@@ -106,6 +108,7 @@ def WriteNormalTag(tag, normals, doNormalize=True):
106108 data = data .tobytes ()
107109 buffer [:len (data )] = data
108110
111+
109112def main ():
110113 """Entry point."""
111114 # Raise an error when the primary selection is not a PolygonObject.
@@ -128,7 +131,7 @@ def main():
128131
129132 # Get the normals from the newly allocated NormalTag.
130133 normals = ReadNormalTag (normalTag )
131- print (f"Normals of the newly allocated tag: { normals } " )
134+ print (f"Normals of the newly allocated tag: { normals } " )
132135
133136 # This should not happen.
134137 if len (phongNormals ) != len (normals ):
@@ -139,20 +142,21 @@ def main():
139142
140143 # Inspect our write operation in the console.
141144 normals = ReadNormalTag (normalTag )
142- print (f"Normals after writing the phong normals: { normals } " )
145+ print (f"Normals after writing the phong normals: { normals } " )
143146
144147 # Start an undo block.
145148 doc .StartUndo ()
146149 # Insert our NormalTag.
147150 op .InsertTag (normalTag )
148151 # For insertions the undo has to be added after the operation.
149- doc .AddUndo (c4d .UNDOTYPE_NEW , normalTag )
152+ doc .AddUndo (c4d .UNDOTYPE_NEWOBJ , normalTag )
150153 # End the undo block.
151154 doc .EndUndo ()
152155
153156 # Notify Cinema and the object that we did made changes.
154157 op .Message (c4d .MSG_UPDATE )
155158 c4d .EventAdd ()
156159
160+
157161if __name__ == "__main__" :
158162 main ()
0 commit comments