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
  • Selection
  • Action if selection has item or not
  • Adding objects
  • To a curve

Was this helpful?

  1. Cinema 4D
  2. Python Cheat Sheet

Maya snippets

Selection

Action if selection has item or not

import maya.cmds as cmds
target = cmds.ls(sl=True)
if target:
    print('yes')
else:
    print('no')

Adding objects

To a curve

import maya.cmds as cmds
from random import uniform
delta = 1.0/10
for n in range(40):
    if uniform(0,1) > 0.5:
        x,y,z = cmds.pointOnCurve( 'curve44', pr=(delta * n), p=True )
        cmds.sphere(r=uniform(0.01, 0.04))
        cmds.move(x,y,z)
import maya.cmds as cmds
from random import uniform
delta = 1.0/10
for n in range(40):
    if uniform(0,1) > 0.5:
        x,y,z = cmds.pointOnCurve( 'curve44', pr=(delta * n), p=True )
        cmds.sphere(r=uniform(0.01, 0.04))
        cmds.move(x,y,z)
  
#----------------------------------------
import maya.cmds as cmds
from mesh_utils import *
from random import uniform
  
positions = get_faces_midpoint('pPlane1', False)
for x,y,z in positions:
    inst = cmds.instance('pCone1')[0]
    y_angle = uniform(0, 360)
  
    cmds.rotate(0, y_angle, 0, inst, relative=True)
    cmds.move(x,y,z, inst)
#----------------------------------------
    
PreviousMaya EnvironmentNextVSFX 705

Last updated 4 years ago

Was this helpful?