Skip to content

Instantly share code, notes, and snippets.

@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()
@internetimagery
internetimagery / anim_export.py
Last active September 27, 2016 13:30
Import / Export basic animation from C4D
# Copy animation crudely to a file and back
import c4d
import c4d.gui as gui
import c4d.storage as storage
import json
import urllib
import os.path
import datetime
import platform
@fusepilot
fusepilot / gist:f18599d8c2489b8be1ac
Last active September 27, 2016 13:34
C4D Activate Camera on Frame Tag
import c4d
import re
"""
1. Create python tag on camera and add this code to it.
2. Duplicate tag to other cameras.
3. Rename your camera layers to match the frame you want it be be active on, e.g., cam-1, Camera01, 01.
"""
def main():
@baku89
baku89 / count_keyframes_c4d.py
Created December 5, 2015 04:33
Count keyframes of active document
from c4d import gui
import shutil
num = 0
def countObjectKeyframe(obj):
global num
tracks = obj.GetCTracks()
@baku89
baku89 / Python Tag
Last active September 27, 2016 13:53
C4D: Make only nth child object visible
# 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
@990adjustments
990adjustments / Toggle-AntiAliasing.py
Created November 2, 2011 02:26
A quick Cinema 4d Python script to toggle anti-aliasing setting.
"""
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
@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
@ruimac
ruimac / Suppress similar color.py
Last active November 14, 2017 18:49
Cinema 4D python script - Suppress similar color
# Script by RuiMac - 09-2015
import c4d
from c4d import gui
#Welcome to the world of Python
def replace(obj,m1,m2):
# while there are still objects...
while obj:
# get all the tags of the object
@NiklasRosenstein
NiklasRosenstein / c4d_IntegrateSplineData.py
Last active November 14, 2017 19:06
Adaptive method for approximating the integral of a c4d.SplineData (i.e. the area "under" the spline).
# Copyright (c) 2016 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