CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
Thread Tools Search this Thread Display Modes
Old 04-10-2013, 11:40 PM   #1
Peter Hunt
Join Date: Jan 2013
Posts: 95
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-11-2013, 12:08 PM   #2
A newbie
zoharl's Avatar
Wellington, New Zealand
Join Date: Mar 2009
Posts: 1,825
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.
Old 04-11-2013, 01:30 PM   #3
Peter Hunt
Join Date: Jan 2013
Posts: 95
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?


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-11-2013 at 01:51 PM.
Old 04-11-2013, 01:30 PM   #4
CGTalk Moderation
CGTalk Forum Leader
Join Date: Sep 2003
Posts: 1,066,478
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 07:51 AM.

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