Maya Particle importer for Grasshopper

<UPDATE> The component has been updated for Grasshopper 0.8. also new option to allow you to not inport the rgbPP attribute.

I have created a new definition for grasshopper that will import particle animations from Maya into grasshopper. The importer works in realtime, so if you have maya and grasshopper opened at the same time any changes to the particles in maya will be reflected in Grasshopper. Right now I only import two attributes, position as point and velocity as a vector. The script is open and easy to add any property you want to carry over. The idea behind the function is to use Maya ability to create “smarter” point cloud using forces and AI. the definition is in the download section at

www.cerver.org


how to use

1. In Maya create a particle system and add a new expression using the dynExport option.

dynExport -atr position -atr velocity -atr rgbPP -f pda NameOfParticle

or

dynExport -atr position -atr velocity -f pda NameOfParticle

Look at the Maya docs if you are not familiar with the command or expressions

2. Maya will write out the particles in real-time usually to a folder named “particles” in you Maya project directory. The file names will be the same name as the particle system name. input the name of the path and the name of the file into Ploc and Pname. For example.

Ploc = C:\Users\robert\Documents\maya\projects\particleTest\particles\test\

Pname= nParticleShape1

3. FRAME will control the frame number of the particle animation in maya

4. SCALE will scale the particle system 5. SWAPY will flip the Y and Z axis

5. UseRGB - if True will try to import the rgbPP attribute.

  • irene schweizer

    hi robert,
    this particle importer sounds really great and i tried to install it but, dont know, its not working. i downloaded the .ghx and .mel file and put the .mel file in the scripts file from maya. than i wrote mp2csv("someName") in the command line and maya shows a file with the right frame. but when i typed the file adress in the grasshopper expression nothing happened.
    so maybe you can explain step by step whats to do!?

    thank you!
  • robert cervellione

    irene,

    you do not need the mell script, that is something different. you only need the grasshopper def. in the grasshopper def is a text panel with instruction on how to use the file. i have also added the same text here.
  • Tommaso Casucci

    Hi robert,
    good work!!
    Does it work in Maya 2011?
  • robert cervellione

    tommaso,

    yes it works in 2011. and on legacy particles or nParticles.
  • Michele

    hi robert,
    I saw your videos, you did something amazing.
    I can't use it, I copied the destination and the name of the file in the right places but it doesn't work. I uploaded a screenshot: The output says that is not possible to find the file. Could you please help me?

  • robert cervellione

    Michele,

    look at the error, does the file "particlesparticleShape1.1.175.pda" actualy exist!!

    first problem is you need to add a "\" at the end of the ploc
    second you particle name is probably "particleShape1" drop the ".1" at the end
  • Michele

    I saw the missing "\" when uploading the pic.
    about the ".1" that's the name of the file as it come out from the dynExport. I even tried to change it but it doesn't work
  • robert cervellione

    so you are 100% sure that "particleShape1.1.175.pda" exists. double check the file extension to make sure you are writing out "pda" files
  • Michele

    The problem is that ".175" in the file name from the output is the frame value (slider): It seems that grasshopper searches for the file from "Pname" but with this ".175" wich is not in the file name, it's just the frame value.
    second point is that (I am sorry I am not so familiar with maya) in this page, when you write about the dynExport, there's this attibute "-atr rgbPP" wich is missing in the instruction you give at your "www.cerver.org" page.
    I tried both of them.
    With the one from "www.cerver.org" I get the problems I wrote before.
    With the one from this page maya tell me:

    "Error: No export done. Could not find this attribute, please make sure all the objects have it: rgbPP"

    Maybe what I am doing with maya is wrong. In this case I will ask a friend of mine to help me with the dynExport and I wont disturb you anymore.
    Anyway I would like to thank you for helping me.
  • robert cervellione

    Michele,

    i have updated my site to include a projects page for this plugin it is under Projects tab. here is a direct link

    http://www.cerver.org/?page_id=363

    i have also updated the definition to include a maya file which should help, so re-download it form the download section. (i hope)
  • Robert Beach

    cool
  • Gerd Fechter

    Does anybody know a similar tool to import particle animations from 3ds Max into grasshopper?????
  • Madu Mohan

    Hi Robert,
    Interesting work.
    I have encountered a couple issues, seems similar to some other peoples comments.
    If you could clarify when you have a chance I would greatly appreciate it as this seems to have quite a bit of potential.
    I’m inclined to think that this is a issue with the dynExport code.
    Heres two attempts below:

    Failure 1: the dynExport code from your text.
    dynExport -atr position -atr velocity -atr rgbPP -f pda particleShape1
    Error in the Maya Script editor after executing the dynExport code:
    “No export done. Could not find this attribute, please make sure all the objects have it: rgbPP//”

    Failure 2: Maya Help mel example, slightly modified with my path.
    2= dynExport -mnf 0 -mxf 200 -os 2 -atr position -atr velocity -p "Part_Test" -f pda;
    Error in the out panel in GH:
    “Attributes do not match intended order or type, current attributes = position velocity should = position velocity rgbPP, change the order to match in your dynExport in Maya

    I’ve been banging my head around with this for a bit, would greatly appreciate your help!
    Many thanks

  • robert cervellione

    Madu,

    the first error is because you did not add a rgbPP attribute to your particle system. a rgbPP is not added to legacy particle systems. i recommend using a nParicle system and use "balls" as the type. this will create a rgbPP attribute on creation

    the second error is because you removed the rgbPP attribute from the dynExport in maya and the code checks for that. i have released a new version that you can get on my site that will allow you to choose weather or not you bring in the rgbPP attribute.

    hope this helps

    -robert
  • Madu Mohan

    Hi Robert,
    Thank you for the reply.
    I’ve downloaded the new version and used the following code from your site:
    dynExport -atr position -atr velocity -atr rgbPP -f pda nParticleShape1;

    However I found when I executed this code with the particle selected, only one pda file was exported to the directory (the one that the slider was currently on)

    So I have modified your code with the following: -mnf 0 -mxf 200

    dynExport -mnf 0 -mxf 200 -atr position -atr velocity -atr rgbPP -f pda nParticleShape1;

    This exported all the pda’s from 0-200 and I was able to then go into grasshopper and move the frame slider to preview the animation.
    Is this correct?
    Or is there a way to play the time slider in maya and have that drive grasshopper?

    Way cool…
    Cheers.
  • robert cervellione

    you do not need to add -mnf 0 -mxf 200

    you need to add the code as an EXPRESSION not as a MEL Script. and make sure the expression is set to "evaluate Always". then maya will evaluate the particles at every frame and will update with any changes made, updating grasshopper in turn.
  • Madu Mohan

    Got it added into the expression editor and it works, Cheers.
    So it continually rewrites the pda files as the time slider plays in maya.
    I guess my question was if there was a way to visually see frame by frame instead of moving the slider manually in grasshopper. Some way to create a connection realtime to the slider in maya and the frame input in grasshopper...
    Many thanks
  • robert cervellione

    yes you can link the maya time slider to the component. it requires a little different expression. i can post an example when i get a chance
  • robert cervellione

    you can also just animate the time slider in grasshopper
  • Madu Mohan

    yea no worries whenever you get a chance, its incredible to open up GH across many platforms.
    Keep up the good work!
  • Alex Diebalek

    Hi Robert!

    Thank you for the nice definiton. it helped me a lot. unfortunately i've got some troubles with importing a single particle system (not nparticles!).

    Grasshopper tells me this:

    'attributes do not match intended order or type, current attributes =
         position velocity
    should =
         position velocity rgbPP
    change the order to match in your dynExport in Maya'

    i'm not working with rgbPP right now because they are no nparticles in my file.

    I was looking for the upgraded gh-def. from your blog, which you told the guys in this forum who had the same problem, but i did not find any file.

    Please, can you help me?

    best,

    Alex

  • Avishek Das

    is there any way to bypass th rgbPP part and continue using legacy particles
  • robert cervellione

    take a  look above at the how to use,  you can omit rgbPP and it will work fine. 

     

    dynExport -atr position -atr velocity -atr rgbPP -f pda NameOfParticle

    or

    dynExport -atr position -atr velocity -f pda NameOfParticle

     

  • robert cervellione

    Alex,

     

    the update is on my site www.cerver.org. and if you using legacy particles then omit the rgbpp part of the expression

  • robert cervellione

    also would everyone please use the new group "cerver tools" for help
  • Avishek Das

    Robert, I have figured out a way..

    We can use still use legacy particle system with rgbPP atr

    1.make a particle grid 

    2.set render apperance as sphere

    3.now go to ''add dynamic attributes'' and select ''color''

    4.now select all the particles and select'' add per particle'' from the dialogue box just appeared

     

    now u can use ''dynExport -atr position -atr velocity -atr rgbPP -f pda NameOfParticle'' command without any error and robert's code does accept it without any error..

     

    if u have any problem mail me @ colors1990@gmail.com

  • Avishek Das

    actually add both...add per particle and add per object

     


  • robert cervellione

    I am glad you figured out rgbpp. Since this is a grasshopper forum I did not get deep into it but per particle attractive are very powerfully. I use rgbpp because in essence it is just 3 numbers r g b. So you can assign many things to it. Say life to r . Age to g. And a hit test b ( 0 for no 1 for yes) and so on. Then in grasshopper you can break the color into its 3 parts and use it for stuff. But you can assign almost anything to a pp attribute