NoSleepCreative Wiki
  • Welcome to NoSleepCreative
  • After Effects
    • Getting Started with Expressions
    • Expressions & Snippets
      • JSX Cheatsheet
      • Expression Troubleshooting
      • Utilities
      • Shape & Mask
      • Type & Text
    • Cookbook
      • Algorithmic
      • Random properties
      • Harmonic Motion
      • Staggering
      • Tessellation & Tiling
      • Type animators
      • Speed lines
      • Radial Array
      • Orb & Trails
      • Shading & Texturing
      • Responsive
      • Automation
      • Setup & Rigs
    • Getting started with Scripting
    • Scripting
      • Utilities
      • Master Properties
    • ScriptUI
  • Studio Ops
    • Tooling
    • Toolkitting
    • Knowledge Base
    • Naming Convention
    • DAM
  • Cinema 4D
    • Formulas
    • Python Cheat Sheet
      • For Artists
      • Maya Environment
      • Maya snippets
      • VSFX 705
    • Cookbook
  • Info
    • About
    • Portfolio
    • Course
    • YouTube
    • Gumroad
    • GitHub
  • Dev
    • archive
      • Webscraping
      • Google Sheets Formulas
      • SQL
      • Terminal
      • C++
      • Unreal Engine
      • Concert Visualization
      • Dome-projection
      • UI UX
      • Professional Etiquettes
      • Woes
      • How to get better
        • Portfolio / Showreel
        • Design with cooking
      • Media theories
        • Post Cinematic Affect
        • Marxism, Reproduction and Aura
        • Heuristics & Authorship
        • 02 Semiotics
        • 3 Process?
        • 05
        • 06 Technology & Mediation
        • Formalism
        • Simulation
        • The Gaze & Media Critique
        • Import
        • 10-12
      • Recommended books
        • 🔴Things I learned
      • Mac Superuser
        • Applescript
      • InDesign
      • Illustrator
      • Blender
      • Premiere Pro
      • Mathematics
        • Probability
        • Linear Algebra
      • Shader Dev
      • Getting Started with After Effects
        • Best Practices
        • Pimping up AE
        • Environment
      • Houdini
        • Cheatsheet
        • Cookbook
        • Techniques
        • Dynamic
        • Rendering & Lighting
        • Animation
        • Particles
        • Others
          • Modeling
          • Fluids - Pyro & Smoke
          • Rendering
      • REGEX
    • Sandbox
      • Nexrender
        • Terminology
        • Project Files Preparation
Powered by GitBook
On this page
  • Unsorted
  • Matrix Array Transformation
  • Position
  • Rotation
  • Scale
  • Color
  • References
  • Formula

Was this helpful?

  1. Cinema 4D

Cookbook

Unsorted

# Get Active Object
obj = doc.GetActiveObject

Matrix Array Transformation

Theory

Position

Selecting a single element

n = 20

# Position: Vector to Real
x = marr[n].off.x 
y = 20
z = marr[n].off.z

marr[n].off = c4d.Vector(x,y,z)

Selecting a single element

for i in range(cnt):
  x = marr[i].off.x 
  y = 20+i*5
  z = marr[i].off.z
  
marr[i].off = c4d.Vector(x,y,z)

Rotation

Single Axis


rot_x = c4d.utils.MatrixRotX(c4d.utils.Rad(45))
rot_y = c4d.utils.MatrixRotY(c4d.utils.Rad(30))
rot_z = c4d.utils.MatrixRotZ(c4d.utils.Rad(45))

marr[6] *= rot_x
   

Multiple Axes with HPB to Matrix

r_x = c4d.utils.Rad(11)
r_y = 0
r_z = c4d.utils.Rad(18)

vect = c4d.Vector(r_x, r_y, r_z)
rotation = c4d.utils.HPBToMatrix(vect,5)

marr[6] *= rotation

Scale

for i in range(cnt):
    x = random.uniform(0.2,1) 
    y = random.uniform(0.2,1)
    z = random.uniform(0.2,1)
    vect = c4d.Vector(x,y,z)
  #  marr[i].Scale(float(i/10))
    marr[i].Scale(vect)

Color

carr = moData.GetArray(c4d.MODATA_COLOR) # Color Array

# Gray Scale
# carr[0] = c4d.Vector(0.5) 

for i in range(cnt):
    r = random.random()
    g = random.random() 
    b = random.random()
    carr[i] = c4d.Vector(r,g,b)
    
# Update Color Array
moData.SetArray(c4d.MODATA_COLOR, carr, hasField)

References

  • C4D SDK Documentation

Formula

Documentation

Alternate intensity based on row number (Animate over time)

mod((id/5);2)?(t;-t)

Animate over time based on the row number sequence

(id/5)/(count/5)*1.5*t
PreviousVSFX 705Nextarchive

Last updated 1 year ago

Was this helpful?

Cinema 4D Python Bytes
Cinema4D Python SDK
C4D Python SDK Extended Github, Plugin Cafe
https://github.com/aturtur/cinema4d-scripts