This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add User Data (ID=1) as Integer | |
# In python tag | |
def main(): | |
b = op.GetObject() | |
idx = b[c4d.ID_USERDATA,1] | |
children = b.GetChildren() | |
for i, c in enumerate(children): | |
v = 2 if idx == i else 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def get_random_color(pastel_factor = 0.5): | |
return [(x+pastel_factor)/(1.0+pastel_factor) for x in [random.uniform(0,1.0) for i in [1,2,3]]] | |
def color_distance(c1,c2): | |
return sum([abs(x[0]-x[1]) for x in zip(c1,c2)]) | |
def generate_new_color(existing_colors,pastel_factor = 0.5): | |
max_distance = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
#http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file | |
url = "http://localhost:5000/" | |
fin = open('simple_table.pdf', 'rb') | |
files = {'file': fin} | |
try: | |
r = requests.post(url, files=files) | |
print r.text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Toggle-AntiAliasing | |
Copyright: Erwin Santacruz, www.990adjustments.com | |
Written for CINEMA 4D R12.016 | |
Name-US: Toggle-AntiAliasing | |
Description-US: A quick toggle for anti-aliasing settings. | |
Make it a button for quick access |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import code | |
def get_module_docstring(filepath): | |
"Get module-level docstring of Python module at filepath, e.g. 'path/to/file.py'." | |
co = compile(open(filepath).read(), filepath, 'exec') | |
if co.co_consts and isinstance(co.co_consts[0], basestring): | |
docstring = co.co_consts[0] | |
else: | |
docstring = None | |
return docstring |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MinMax(object): | |
""" | |
Calculate various area metrics from a list of points, | |
such as min, max, midpoint, radius and size. | |
""" | |
def __init__(self): | |
super(MinMax, self).__init__() | |
FLOATMIN = sys.float_info[3]-1000 # workaround for underflow error | |
FLOATMAX = sys.float_info[0] | |
self.min = c4d.Vector(FLOATMAX, FLOATMAX, FLOATMAX) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Plane(object): | |
"""Represents a plane defined by position and normal vector""" | |
def __init__(self, pos, n): | |
super(Plane, self).__init__() | |
self.pos = pos | |
self.n = n.GetNormalized() | |
if DEBUG: print "self.pos = %r, self.n = %r" % (pos, n) | |
def setN(self, newn): | |
self.n = newn.GetNormalized() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Helpers(object): | |
"""Contains various helper methods.""" | |
def __init__(self, arg): | |
super(Helpers, self).__init__() | |
@staticmethod | |
def readConfig(filepath=None): | |
""" | |
Read settings from a configuration file. |