Skip to content

Instantly share code, notes, and snippets.

@bonsak
bonsak / c4d-toggle-live-rectangle.py
Created October 21, 2015 20:09
Script to toggle between Live selection and Renctangle
import c4d
​
def main():
if c4d.IsCommandChecked(200000083):
# If Live switch to rect
c4d.CallCommand(200000084)
else:
# Else switch to Live
c4d.CallCommand(200000083)
@bonsak
bonsak / c4d-reset-object-axis.py
Created September 22, 2015 20:02
c4d-reset-object-axis
import c4d
# Slightly modified version of Lennart's (tca studios) script from this thread:
# http://www.plugincafe.com/forum/forum_posts.asp?TID=6600&KW=&PID=27379#27379
def main():
if op is None: return False
oldm = op.GetMg()
points = op.GetAllPoints()
@bonsak
bonsak / c4d-select-points-visible-to-camera.py
Created September 20, 2015 21:23
c4d-select-points-visible-to-camera
import c4d
from c4d import gui, documents
def main():
# BaseDraw
bd = doc.GetActiveBaseDraw()
# The camera view
view = bd.GetSafeFrame()
@bonsak
bonsak / c4d-select-nth-point.py
Last active September 27, 2016 13:19
C4D Python: Select every nth point in object
import c4d
from c4d import gui
def main():
doc = c4d.documents.GetActiveDocument()
op = doc.GetActiveObject()
if op is None or op.GetType() != c4d.Opolygon: return
bs = op.GetPointS()
@bonsak
bonsak / udim.py
Last active March 26, 2018 17:35
Mimic UDIM in Cinema4D
import re, c4d
from c4d import documents as docs
# Python tag that Mimics UDIM for texture tags in Cimena4D.
# Name your texture tags 1001, 1002, 1021 etc
# Doesn't check the number of tag on each row
# Iterates through all tags on the object that this script is attached to
# Find all texture tags with with name that starts with 10 (UDIM style)
# Check if they are of type texture (5616)
@bonsak
bonsak / 0_reuse_code.js
Created May 31, 2014 19:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bonsak
bonsak / gist:619464e15b01d1b2fdb6
Last active August 29, 2015 14:01
wpdb - get title from posttype
<?php
/*-----------------------------------------------------------------------------------*/
/* wpdb get title from post type
/*-----------------------------------------------------------------------------------*/
$post_type = "project";
$results = $wpdb->get_results(
$wpdb->prepare( "
SELECT post_title
FROM $wpdb->posts
@bonsak
bonsak / gist:9178220
Created February 23, 2014 22:23
Toggle
import c4d
if c4d.IsCommandChecked(12101):
c4d.CallCommand(12298) # Model
elif c4d.IsCommandChecked(12298):
c4d.CallCommand(12101) # Object
@bonsak
bonsak / gist:9100485
Last active August 29, 2015 13:56
Iterate a c4d bascontainer
import c4d
def main():
bc = c4d.GetWorldContainer()
for index, value in bc:
# If value is "basecontainer"
print "Index: %i, Value: %s" % (index, str(value))
if bc.GetType(index) == 132:
print " Container: %i, Value: %s" % (index, str(value))
@bonsak
bonsak / Node.sublime-build
Created October 15, 2013 14:39
Node Sublime Build
{
"cmd": ["node", "$file"],
"selector" : "source.js",
"path" : "/usr/local/bin"
}