This file contains 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. |
This file contains 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 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 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 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 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 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 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
# @rosensteinn #c4dpytask #medium How can you load a texture and assign | |
# it to a plane with image dimensions? (you need a LoadDialog, BaseBitmap | |
# and Oplane) | |
import c4d | |
def main(): | |
# Poll the user for a filename. We specify that the file-type may be | |
# an image only. | |
filename = c4d.storage.LoadDialog(c4d.FILESELECTTYPE_IMAGES) |
This file contains 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
# Copyright (c) 2013, Niklas Rosenstein | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in |
OlderNewer