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 Tools Search this Thread Display Modes
  04 April 2013
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
 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
  04 April 2013
I think the particle command should do the trick

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

`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.
  04 April 2013
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)
 #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?


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.
  04 April 2013
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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
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
Society of Digital Artists

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

All times are GMT. The time now is 09:37 AM.

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