Get position of particles in pymel

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
Get position of particles in pymel

Hi, I can't seem to find a simple way of getting the position of all the particles from an emitter.

I was thinking something around the lines of
-create emitter
-move forward one frame
-get and store the position of every particle in a list
-move back a frame

Now, I've got the first part sorted, the below code will create a shape and attach an emitter to it, but I just don't seem to understand any answers I've found from google

import pymel.core as pm
 import maya.cmds as cmds
 cmds.polyCube(w=50,h=50,d=50,n='cube1')
 pm.emitter( n='myEmitter', type ='surface', r= 1000, sro = 0)
 pm.particle( n='emittedParticles' )
 pm.connectDynamic( 'emittedParticles', em='myEmitter' )



Any help would be appreciated, thanks
 
Old 04 April 2013   #2
I think the particle command should do the trick

http://download.autodesk.com/us/may...n/particle.html

Try query the attribute position of a particle, as done in

http://www.creativecrash.com/forums...ticle-position-

`particle -attribute position -order $n -query particle1` ,


look at the doc how to convert the mel into python. Meaning, compare the mel examples for the particle command to the python examples of the particle command, and try to work it out.
 
Old 04 April 2013   #3
Thanks, I've managed to convert that part now, however, I can't seem to build the array. The code I have so far is below, I've been using the getParticleAttr command, but it doesn't like whatever I put into where it says 'emittedParticles'



 #create objects
 py.currentTime( 1, edit = True, update = True)
 cmds.polyCube(w=50,h=50,d=50,n='cube1')
 
 #create emitter
 py.emitter( n='myEmitter', type ='surface', r= 1000, sro = 0)
 py.particle( n='emittedParticles' )
 py.connectDynamic( 'emittedParticles', em='myEmitter' )
 
 #get array
 py.currentTime( 2, edit = True, update = True)
 array = py.getParticleAttr( 'emittedParticles', at='Position', array=1 )
 py.particle( attribute = 'Position', order = array, query = True )
 



The actual page is here, does anyone have any idea what I'm doing wrong?
http://download.autodesk.com/global...getParticleAttr

Thanks


EDIT: The lecturer helped out on his own accord as he knew there wasn't much documentation on it, just for if anyone comes across this in a google search, this is the basic idea.

particleEmitter = py.particle( n='emittedParticles' )
#connect particles to shape and set frame to 2 (otherwise there won't be any particles)
num = particleEmitter[1].num()
for i in range(num):
	particleInfo = particleEmitter[1].Point( 'emittedParticles', i )
	particlePos = particleInfo.position

Last edited by JustAnotherGuy : 04 April 2013 at 01:51 PM.
 
Old 04 April 2013   #4
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:48 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.