Skip to content

Instantly share code, notes, and snippets.

💭
Mostly inactive, sometimes active, I really don't feel like updating my status

Frank Willeke fwilleke80

💭
Mostly inactive, sometimes active, I really don't feel like updating my status
Block or report user

Report or block fwilleke80

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fwilleke80
fwilleke80 / c4d-is-inside-geometry.py
Last active Aug 19, 2019
[C4D] A function that uses GeRayCollider to determine whether a given position is inside a polygon object's volume or not. Only works reliably with closed polygon objects. Absolutely not optimised for speed (you would probably want to do the collider initialisation and position transformation elsewhere)
View c4d-is-inside-geometry.py
def isInside(pos, polyOp):
"""Check whether a given position is inside a (closed!) polygon object.
:param pos: A position to test for, in global space
:param polyOp: A PolygonObject
:return: True if pos is inside polyOp, otherwise False
"""
# Init GeRayCollider
collider = c4d.utils.GeRayCollider()
collider.Init(polyOp)
@fwilleke80
fwilleke80 / c4d-get-plugin-flags.py
Created Jul 18, 2019
[C4D] A function that returns a string with the plugin flags for the BasePlugin of a BaseList2D
View c4d-get-plugin-flags.py
def GetPluginFlags(bl):
"""Return string with all plugin flags of a given BaseList2D element
@param bl The BaseList2D element (e.g. BaseObject, BaseTag,
BaseVideoPost, BaseMaterial, BaseShader, et cetera)
@return A string containing all the identified plugin flags
"""
if bl is None:
return ''
@fwilleke80
fwilleke80 / c4d-get-plugin-name.py
Last active Jul 18, 2019
[C4D] A function that finds the name of a plugin by ID, and even works for builtin BaseList2D elements that are not registered plugins
View c4d-get-plugin-name.py
def GetPluginName(pluginId, pluginType=c4d.PLUGINTYPE_ANY):
# Check if it's the ID of a registered plugin
foundPlugin = c4d.plugins.FindPlugin(pluginId, type=pluginType)
if foundPlugin is not None:
return foundPlugin.GetName()
# It's not the ID of a registered plugin, but might still be a builtin
# Try to allocate a new instance, and get type name
newObj = c4d.BaseList2D(pluginId)
if newObj is not None:
return str(type(newObj).__name__)
@fwilleke80
fwilleke80 / c4d-serial-analyzer.pyp
Last active Jul 11, 2019
[C4D] A Python plugin for Cinema 4D that will analyse a given serial number and present information about it
View c4d-serial-analyzer.pyp
import c4d
ID_SERIALANALYZER = 1052961
NAME_SERIALANALYZER = 'Serial Analyzer'
VERSION_SERIALANALYZER = '0.3'
HELP_SERIALANALYZER = 'Analyze Cinema 4D serials'
def analyze_serial(c4dSerial=''):
@fwilleke80
fwilleke80 / c4d-tag-show-dirty-checksums.pyp
Last active May 9, 2019
[C4D] A small Tag plugin that will output the most important dirty checksums for the object it's attached to into the console. Quite handy to check if an object keeps refreshing or rebuilding its cache. Simply attach the "Show Dirty Checksums" tag to an object and watch the Python console output.
View c4d-tag-show-dirty-checksums.pyp
import c4d
ID_SHOWDIRTYCHECKSUMSTAG = 1052821
class ShowDirtySumsTag(c4d.plugins.TagData):
def Init(self, node):
priorityData = node[c4d.EXPRESSION_PRIORITY]
if priorityData is not None:
@fwilleke80
fwilleke80 / c4d-document-to-json.py
Last active Jun 3, 2019
[C4D] Export objects and tags of a document to a serialised JSON file
View c4d-document-to-json.py
"""
Name-US:Export document as JSON
Description-US:Export document to JSON
"""
import c4d
import json
def serialize_data(data):
"""Serialize special data types
@fwilleke80
fwilleke80 / c4d-create-random-scene.py
Last active Jul 17, 2019
[C4D] A nicely customisable Python script that creates complex random scene hierarchies in Cinema 4D. Good for performance testing in cases where number of objects is an issue.
View c4d-create-random-scene.py
"""
Name-US:Create random scene...
Description-US:Create random scene (hold SHIFT to use previous settings, hold CTRL to forget previous settings)
"""
import sys
import time
import json
import random
import c4d
@fwilleke80
fwilleke80 / c4d-save-as-template.py
Last active Jul 17, 2019
[C4D] Save current document as template. Like the built-in script, just better, and in Python.
View c4d-save-as-template.py
"""
Name-US:Save as template
Description-US:Saves the current document as template (hold CTRL to remove existing template, hold SHIFT to skip question dialog)
Name-DE:Als Template speichern
Description-DE:Speichert das aktuelle Dokument als Template (CTRL gedrückt halten um vorhandenes Template zu entfernen, SHIFT gedrückt halten um Abfrage zu überspringen)
"""
import os
import c4d
@fwilleke80
fwilleke80 / c4d-pytag-polygonarea.py
Last active Jul 17, 2019
[C4D] Copy this code into a Python tag and it will calculate the area of any PolygonObject it is attached to.
View c4d-pytag-polygonarea.py
import c4d
def calc_polygon_area(polygon, points):
"""Calculate the area of a polygon
@param polygon A CPolygon object
@param points List of c4d.Vector with point positions
@return The area of the polygon
"""
# Calculate area for the triangular polygon
p1 = points[polygon.a]
@fwilleke80
fwilleke80 / c4d-r20-multiinstance-test.py
Last active Jul 17, 2019
[C4D] Create a bunch of coloured object clones using the R20 Multi Instance feature
View c4d-r20-multiinstance-test.py
"""
Name-US:Multi Instance test
Description-US:Create a bunch of colored object clones using the R20 MultiInstance feature
"""
import c4d, time
COUNT_X = 200
COUNT_Z = 300
MARGIN = 150.0
NOISE_HEIGHT = 1200.0
You can’t perform that action at this time.