Skip to content

Instantly share code, notes, and snippets.

View danvas's full-sized avatar

Daniel Vasquez danvas

View GitHub Profile
import pymel.core as pm
def chDir(object, *filtr):
"""Check methods: Returns a list of methods bound to the instanced object. Filter search with string(s) filtr."""
if not filtr:
return [meth for meth in dir(object)]
else:
return [meth for string in filtr for meth in dir(object) if string in meth]
"""
*** Cache Cloud ***
Version 0.9.0
by Daniel Vasquez
Updated: August 12, 2011
Email: dan@heylight.com
Web: heylight.com
Description:
Python script that creates Maya Particle Disk Cache (PDC) files from a sequence of point cloud data, and also gives you the choice of importing a single point cloud. It could be useful with all the open source data being released from Kinect hacks or 3D scanners. You can start by playing around with Radiohead's House Of Cards data: http://code.google.com/p/radiohead/downloads/list
import pymel.core as pm
def getCurves(tstep, deg=3):
"""Generate cv curves from particle paths.
Sample the path every tstep in the current time range and generate curve with degree deg.
Before executing, select particle in object mode (i.e. curves from all points) or component mode (i.e. curves from selected points)."""
global curvesData #FIX! I hate this global variable... find other way to collect data
curvesData = {}
tmin = int(pm.playbackOptions(q=1, min=1))
tmax = int(pm.playbackOptions(q=1, max=1))
@danvas
danvas / vect.py
Created September 16, 2011 21:20
To find vector between curve points.
def vect(curv, pt2 = 1, pt1 = 0):
"""Returns a vector from two cvs on a curve. The argument curv is a PyMEL instance or string. For example:\vect('curve1', pt2 = 5, pt1 = 2) gives you a direction (i.e. vector) from cv[2] to cv[5] in curve1"""
if type(curv) == str:
curv = pm.ls(curv)[0]
if curv.getShape().numCVs() <= pt2:
print('\n!! There are {0} cvs. Make sure your pt2 value is less than {0}. !!'.format(curv.getShape().numCVs()))
else:
return [curv.cv[pt2].getPosition()[0] - curv.cv[pt1].getPosition()[0],
@danvas
danvas / hlCopyAttr.py
Created October 13, 2011 05:59
PyMel function that copies the value(s) of the attribute from sourceObj to targetObj. Handles multi-attributes.
import pymel.core as pm
sourceObj = pm.ls('aFluidShape')[0]
targetObj = pm.ls('myFluidShape')[0]
def hlCopyAttr(sourceObj, targetObj, attribute):
"""Copies the value(s) of the attribute from sourceObj to targetObj. Handles multi-attributes."""
if pm.attributeQuery(attribute, node = targetObj.name(), exists=True): # Execute only if the entered attribute exists
multiAttrCheck = pm.attributeQuery(attribute, node=targetObj.name(), m=1) # Check if it's a multi-attribute or not
if multiAttrCheck: # If the attribute is a multi-attribute, copy the values from each instance
@danvas
danvas / ex05_11.cpp
Created October 13, 2011 21:10
C++ code that calculates compound interests. (Exercise from Deitel & Deitel)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
for (int interest = 5; interest <=10; interest++)
{
double amount = 1000.00;
@danvas
danvas / Ex08_25.cpp
Created November 17, 2011 04:27
A maze!
// Exercise 8.25 Solution: Ex08_25.cpp
// This solution assumes that there is only one
// entrance and at most one exit for a given maze, and
// these are the only two zeroes (at most) on the borders.
// NOTE: Your solution should work for all 3 test mazes below
#include <iostream>
using std::cin;
using std::cout;
@danvas
danvas / maze1.1.cpp
Created November 17, 2011 23:41
maze
// Assignment 07: maze.cpp
// Program that raverses mazes on a right-hand rule basis.
// Author: Daniel Vasquez
// Date: Nov. 17th, 2011
#include <iostream>
using std::cin;
using std::cout;
enum Direction { DOWN, RIGHT, UP, LEFT };
@danvas
danvas / Complex.cpp
Created November 22, 2011 02:30
Member-function definitions for class Complex.
// Assignment 8: Complex.cpp
// Member-function definitions for class Complex.
// Author: Daniel Vasquez
// Date: Nov. 24th, 2011
#include "Complex.h"
// Default constructor
Complex::Complex( )

Keybase proof

I hereby claim:

  • I am danvas on github.
  • I am danvas (https://keybase.io/danvas) on keybase.
  • I have a public key ASDUr9SFP2AJGFF3T7W__gbPSeHP8C5syP_Y0ZixtY0eAwo

To claim this, I am signing this object: