import maya.cmds as cmds
import maya.OpenMaya as om
# This point would refer to our particle birth location
point = om.MPoint(*cmds.xform(q=True, t=True, ws=True))
# Loading the curve, in case we didn't have it already
curve = om.MObject()
sel = om.MSelectionList()
om.MGlobal.getSelectionListByName("curveShape1", sel)
sel.getDependNode(0, curve)
curveFn = om.MFnNurbsCurve(curve)
# Have to use pointers to get double data
double1 = om.MScriptUtil(0.0)
double2 = om.MScriptUtil(0.0)
ptr1 = double1.asDoublePtr()
ptr2 = double2.asDoublePtr()
# Get the parameter range of the curve
curveFn.getKnotDomain(ptr1, ptr2)
start = double1.getDouble(ptr1)
end = double2.getDouble(ptr2)
# Get the parameter value for our point location
curveFn.getParamAtPoint(point, ptr1, 0.5)
param = double1.getDouble(ptr1)
# Normalize to 0-1
norm = param / (end-start)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/46b14d6f-4446-45a1-b484-0d5d2a108fee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
// Error: An execution error occurred in the creation expression for particleShape1. //
# Error: RuntimeError: (kInvalidParameter): value not in valid range #
point = om.MPoint(*cmds.xform(q=True, t=True, ws=True))point = om.MPoint(*cmds.xform('particle1.pt[particleId]', q=True, t=True, ws=True))
//see: http://mayaspiral.blogspot.com/2013/04/python-getting-particle-rgbpp-and-apply.html (Note: For now I'm doing all this from within the Expression Editor for particleShape1; which means that I wrapped each line of your script in python() commands and am executing it from within the Expression Editor.)
//get particleId via MEL
$pid = particleShape1.particleId;
//pass MEL variable to python, see: http://forums.cgsociety.org/archive/index.php/t-696519.html
string $s = "pid = " + $pid;
string $sCMD = "python(\"" + $s + "\")";
eval($sCMD);
//create particleIdString for xform command
python("particleIdStr=\"particle1.pt[\" + str(pid) + \"]\"");
python("point = om.MPoint(*cmds.xform(particleIdStr, q=True, t=True, ws=True))");Oh I hope I didn't mislead you too much on that. The part at the beginning was really a temp example solution to producing a point. I assumed you would be slotting in your own source for the particle birth location. Mine was just grabbing a point off a locator for test.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/141ca6f5-bb8a-4936-95f4-4312710e5d7d%40googlegroups.com.