Skip to content

Instantly share code, notes, and snippets.

@gr4ph0s
gr4ph0s / c4d_Shortcut_from_pluginID.py
Created April 26, 2018 10:51
Get the shortcut qualifier + Key assigned to a pluginID
for i in xrange(0,c4d.gui.GetShortcutCount()):
short = c4d.gui.GetShortcut(i)
if short[c4d.SHORTCUT_PLUGINID] == c4d.IDM_UNDO:
shortcutQualifier = short.GetInt32(0)
shortcutKey = short.GetInt32(1)
print shortcutQualifier, shortcutKey
@gr4ph0s
gr4ph0s / TestImport.py
Created December 6, 2017 18:07
Check if redshift module can be imported
import imp
import c4d
class ImportTester(type):
_HaveBeenCalled = False
_CanImport = False
@classmethod
def _CheckImport(cls, clsName):
# If we already test, we return the cached value
@gr4ph0s
gr4ph0s / A minified version of my module C4D_RedshiftWrapper_API
Last active December 6, 2017 18:31
C4D_RedshiftWrapper_API_Minified.py
import zlib, base64
exec(zlib.decompress(base64.b64decode('eJy9G2tzIkfuu3/FLF8WcoT1a727riMVG7y7VIztMthXqVyKtKENc54HNzPY5n79Sa1WP2YAY+dyqVroltRqtR7dknDCeJ5mRTA+nOyENISvnSJbHu8EGpDJST4L74sd+TyW8wIQc5HnO+MIPoOeohnKvJBZvVjOZQPwo+/iUZ5KmXREFMlJ+6uIcgngjkiIniE/KyaxLGbpZCeYyHugmcnxA1HVx1HehH8XIlZsg/A+gGmrxB4xIGSxyBJCm20AQScJ8Cyt+zCZjOJ0sohkndkizl/UHmYL6bDUUzq8Pu9ZlqWZ4sv8g9GI1DUaebzXMS9xX8c+mGdhUmzLXGvVctcApdjRGLRFDJo/iGwKnz88POGAdZukxVr90k6ObWrsFrWGYxkji2uUfDEH53A9Ba3aaBmRSuKgtkFulwUdhFyuLwvRF0U9vfuXHBco/EU6kZ00SrM2+HHrFqBpVt9tfW7utg7xH3CEBSfZeBa2a+qrAJpFJqIaYrKOyNo1+LgSoGwFKr6LEGD4SfNeMhbJRLZrepCPJZN25b1YREW7BmOZhZppcRpJoMssWAMIO5iJSfqkkIWkiUY8hEm7hp96Dh5QwL70rWGDAQAWd4NFdi/GcjBGJsDY6mcon1/WzxdU0NHBR/jc3f0MSoJVJ5egofguhNNdjsfRIg9TFAQwHRH3xRz1FMsMDDDX4EX2KECXIKIZEuYiDXOAXg/UgGDXIp4jCL8JMoBRhGqCMa7Vc0L+I0S++Pk1g23dE94UYZS/fMaDwy9wvI97h809OOBNcbqI58oQ7ZoZqt0IRVA63I1ygpOiQOc47PIkvFsoO8AC8SAJp0YKdtMlIeCMN7nMuqIQCqCQnTTJC5GAqxzuwn97e/u7Ct4N83kEhmzXeBSTd1mUltnFu7J/zWSeyKhd0wMj/lWaoyx6GBZkTsJdgyOnMXk5ja2oN90eymlPAVM51btdp
@gr4ph0s
gr4ph0s / Marker_exemple.py
Created August 24, 2017 19:11
Exemple for add / get marker inside c4d through python
"""
Exemple for add / get marker inside c4d through python.
24/08/2017
More informations => https://www.c4dcafe.com/ipb/forums/topic/99715-xpresso-using-marker-data/
"""
import c4d
def get_all_marker(doc):
markers_list = list()
@gr4ph0s
gr4ph0s / vertex_map_exemple.py
Last active November 14, 2021 17:47
Exemple for get / set VertexMap inside c4d through python.
# coding: utf-8
"""
Exemple for get / set VertexMap inside c4d through python.
Show an exemple of GetLowlevelDataAddressR / GetLowlevelDataAddressW
"""
__author__ = 'Adam Maxime - Graphos <gr4ph0s(at)hotmail.fr>'
__version__ = '1.0'
@gr4ph0s
gr4ph0s / SetAxisRotation.py
Created July 17, 2017 20:30
[c4d]Set axis rotation
#Set axis rotation of an object (didn't support spline in bezier mode)
#17/07/2017
#More informations about csv structure => http://frenchcinema4d.fr/showthread.php?81748-Besoin-d-aide-pour-un-code-python
import c4d
def LocalToGlobal(obj, local_pos):
obj_mg = obj.GetMg()
return obj_mg * local_pos
def GetPointGlobal(obj):
@gr4ph0s
gr4ph0s / csv_import_exemple.py
Last active April 4, 2023 09:08
[c4d]CSV import exemple
#CSV Importer exemple by graphos
#12/07/2017
#More informations about csv structure => https://www.c4dcafe.com/ipb/forums/topic/99062-can-objects-be-created-with-python/
import c4d
import csv
def add_mesh(num, name, r_h, p_x, p_y, outer_radius):
#Create obj in memory
disc_obj = c4d.BaseObject(c4d.Odisc)
@gr4ph0s
gr4ph0s / [C4D]PoseMasterUi_Exemple.py
Created May 23, 2017 11:41
Exemple of GeUserArea who imitate browser
# coding: utf-8
"""
A GeUserArea Exemple for display multiple content.
Hardly based on https://github.com/NiklasRosenstein/c4d-2048 from Niklas
"""
__author__ = 'Adam Maxime - Graphos <gr4ph0s(at)hotmail.fr>'
__version__ = '1.0'
import c4d
"""
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Gr4ph0s wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return :)
* ----------------------------------------------------------------------------
"""
import c4d
@gr4ph0s
gr4ph0s / [C4D]Unique material per face.py
Last active June 1, 2022 21:39
C4D create unique material per face
import c4d
import random
#create a selection for each polygon
def create_poly_selection(obj):
poly_count = obj.GetPolygonCount()
tags = list()
for i in xrange(poly_count):
#create the tag and name it by poly_id
tag = c4d.SelectionTag(c4d.Tpolygonselection)