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 c4d | |
def main(): | |
if op is None: | |
print("No object selected.") | |
return True | |
if op.GetType() != c4d.Opolygon: | |
print("Selected object is not a PolygonObject.") | |
return True |
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 c4d | |
import math | |
FREQUENCY_X = 2.5 | |
FREQUENCY_Z = 1.8 | |
OFFSET_X = 0.5 | |
OFFSET_Z = 0.0 | |
AMPLITUDE_X = 100.0 | |
AMPLITUDE_Z = 100.0 | |
MULTIPLY_Y = 20.0 |
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
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) |
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
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 '' |
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
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__) |
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 c4d | |
ID_SHOWDIRTYCHECKSUMSTAG = 1052821 | |
class ShowDirtySumsTag(c4d.plugins.TagData): | |
def Init(self, node): | |
priorityData = node[c4d.EXPRESSION_PRIORITY] | |
if priorityData is not 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
""" | |
Name-US:Export document as JSON | |
Description-US:Export document to JSON | |
""" | |
import c4d | |
import json | |
def serialize_data(data): | |
"""Serialize special data types |
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
""" | |
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 |
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
""" | |
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 | |
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 c4d | |
def calc_polygon_area(polygon, points, mtx = c4d.Matrix()): | |
"""Calculate the area of a polygon | |
@param polygon A CPolygon object | |
@param points List of c4d.Vector with point positions | |
@param mtx Optional globla matrix of the polygon object, to take object scale into account | |
@return The area of the polygon | |
""" | |
# Calculate area for the triangular polygon |
NewerOlder