Skip to content

Instantly share code, notes, and snippets.

@Squid3d
Squid3d / Walking_with_yield.py
Created March 5, 2015 03:46
using yield to iterate c4d object/tag and materials
import c4d
def walk_objects(obj):
if obj:
yield obj
for x in walk_objects(obj.GetDown()): # happily fail on tags and materials
yield x
for x in walk_objects(obj.GetNext()):
yield x
@baku89
baku89 / mat2quat.py
Created November 1, 2015 14:48
Extract quaternion in right-hand rule from affine matrix in left-hand rules
# http://afni.nimh.nih.gov/pub/dist/src/pkundu/meica.libs/nibabel/eulerangles.py
import eulerangles
import c4d
threeMat = c4d.Matrix().Scale(c4d.Vector(1, 1, -1))
def mat2quat(mat):
mt = threeMat * m
v1, v2, v3 = mat.v1, mat.v2, mat.v3
rotMat = [