Skip to content

Instantly share code, notes, and snippets.

View hanswillem's full-sized avatar

Hans Willem Gijzel hanswillem

View GitHub Profile
@hanswillem
hanswillem / userDataButton.py
Last active September 27, 2016 14:21
Code to make use of the user data button
#put the code in a python tag
#add a user data button to the tag
import c4d
#user data button
def message(id, data):
if id == 17:
print "UserData-ID: ", data["descid"][1].id
@hanswillem
hanswillem / getAllObjects.py
Last active August 29, 2015 14:07
Function that returns all objects in the hierarchy
#GetAllObjects
def getAllObjects():
allObjs = []
def itterate(obj):
while obj:
allObjs.append(obj)
itterate(obj.GetDown())
obj = obj.GetNext()
return allObjs
obj = doc.GetFirstObject()
#sort a list of object based on an attribute or a method of the object
from operator import attrgetter, methodcaller
class Person(object):
def __init__(self, name, age):
self.age = age
self.name = name