Skip to content

Instantly share code, notes, and snippets.

View gwyllo's full-sized avatar

Gwyllim Jahn gwyllo

View GitHub Profile
@gwyllo
gwyllo / gist:6292632
Created August 21, 2013 10:02
Types of loops and moving in python
#import the pymel module
from pymel.core import *
#grab our box shape node from maya
myBox = PyNode('pCubeShape1')
#create a "for each loop" to iterate over
#the vertices in the mesh.
for currentVertex in myBox.verts:
#print the position
@gwyllo
gwyllo / gist:6292149
Created August 21, 2013 09:13
Conditionals intro
#import the pymel module
from pymel.core import *
#grab our box node from maya
myBox = PyNode('pCube1')
#lets check the x pos of our box
#using a conditional statement
#conditional syntax is
#if (variable to check) (condition to check) (:)
@gwyllo
gwyllo / gist:6277779
Created August 20, 2013 06:37
Looping and Vectors
from pymel.core import *
import pymel.core.datatypes as dt
#create a function to find nearest neighbour
#start by getting the particles
particles = PyNode('particleShape1')
#loop through points in the particle system
for p in particles.points:
@gwyllo
gwyllo / gist:6276845
Last active December 21, 2015 08:18
Meshlab Deformation Functions
//The following deforms the mesh using the red channel
//and scales the deformation by 0.2 - this means pure
//red vertices will move normal to the mesh 0.2 units and
//vertices with no red colour will move 0 units (stay put)
x = x+(nx*(r/255))*0.2
y = y+(ny*(r/255))*0.2
z = z+(nz*(r/255))*0.2
#some different data types in python
#remember, we use variables as a way of making our code make sense to us
#variables point to data in our program
#in python we don't need to specify data types for variables
#python figures this out itself
myFirstName = "Gwyll"
myLastName = "Jahn"
@gwyllo
gwyllo / Modifying meshes with colours
Last active December 20, 2015 17:49
Mesh Subobjects and Colours
#Use colours from one mesh to modify another
from pymel.core import *
#get the objects
geomColoured = PyNode('pCubeShape1')
geomMod = PyNode('pCubeShape2')
#store the colour array
colours = geomColoured.getColors()
@gwyllo
gwyllo / Linking Attributes
Created August 7, 2013 03:04
Leviathan Pastes
#Connect camera xpos to xscale of a new cube
from pymel.core import *
cam = general.PyNode('persp')
c = polyCube(name='testCube')[0]
cam.tx >> c.sx # connect
print cam.tx.outputs() #test
#Connect outmesh of one geom to inmesh of another