Конверсия Instancer’а в геометрию


Type: Python Script (py)
Name: sag_instancerToGeometry
Version: 1.4
Released: 2012.05.05
NEW REWORKED VERSION IS CALLED ark_instToGeo AND AVAILABLE HERE

v1.4 - corrected GUI for older maya versions v1.3: - doesn't set visibility to off prior to the starting frame of conversion - doesn't pay attention to 'start from current frame' if custom range is defined v1.2: - reworked GUI - uses long names correctly (no problems with objects of the same name anymore) - doesn't freeze source objects' rotations or error if channels have keyframes - keeps input connections for instances also - works with different rotation orders of source objects and instancer itself - each baked object is inside it's own group which actually gets all keyframes - works with any linear units of the scene (switches to cm and back, actually) v1.1: - duplicates now maintain original input connections - only translate, rotate, scale and visibility are keyframed now

Практически каждый раз когда использую instancer для размножения геометрии по частицам, в итоге неминуемо хочется перевести полученный результат в обычные объекты с ключевой анимацией, дабы подправить отдельные из них или удалить вовсе.

Вот наконец-то собрался и написал утилиту для решения этой задачи.

sag_instancerToGeometry Interface

Использование:

from sag_instancerToGeometry import *
sag_instancerToGeometry()

Опции:

Make Duplicates/Instancesв первом случае созданные объекты будут независимыми дубликатами, во втором – инстансами от исходного объекта (который воткнут в instancer);

Start from Current Frameесли включено, вне зависимости от таймлайна или выставленного вручную диапазона фреймов, начнет конвертацию с текущего фрейма;

Playback/Custom Rangeв первом случае диапазон фреймов будет взят из таймлайна, во втором – можно ввести значения начального и конечного фрейма;

Convert[…описание оказалось столь длинным и замороченным, что было удалено редактором…]

Helpлинк на эту страницу.

Примечания:

Разумеется, есть ряд ограничений и попросту недоработок… Из тех что могу сейчас отметить:

float $vel[] = velocity;
float $ang[] = `angleBetween -euler -v1 1 0 0 -v2 $vel[0] $vel[1] $vel[2]`;
rotPP = <<$ang[0], $ang[1], $ang[2]>>;

В общем, пробуйте, пользуйтесь и пишите багРепорты/пожелания – я постараюсь их исправить/добавить.

Several Instancers Converted into Geometry Simultaneously

Several Instancers Converted into Geometry Simultaneously

Posted on November 14, 2009 at 20:37 by · Permalink
In: FX · Tagged with: , , , , , , ,

59 Responses

Subscribe to comments via RSS

  1. Written by leo369
    on 17 November 2009 at 5:44
    Permalink

    hello,friend,can you send python script to me
    mail:yuyu8401936@hotmail.com

  2. Written by Владимир
    on 23 November 2009 at 19:33
    Permalink

    Отличная утилита!!!

  3. Written by Dan Shumaker
    on 11 June 2010 at 0:14
    Permalink

    I’m getting a “Bad Magic Number” error when trying to import.

    Can you send me the script please? dans@floathybrid.com

    Thanks.

  4. Written by Sagroth
    on 11 June 2010 at 3:23
    Permalink

    I’ve put original .py instead of compiled .pyc, so there should be no issues anymore.

    Положил исходный .py вместо скомпилированного .pyc, поэтому проблем больше не должно быть.

  5. Written by Mostafa
    on 23 June 2010 at 17:13
    Permalink

    this is awesome man. thanks a lot.

  6. Written by sanctus
    on 6 August 2010 at 16:15
    Permalink

    Возможно вас заинтересует http://somesanctus.blogspot.com/2010/08/smartrotation.html
    и вы пересмотрите свое отношение к каналам Aim и Up
    это – пожелание включить их в утилитую.

  7. Written by Sagroth
    on 6 August 2010 at 22:28
    Permalink

    Да, спасибо. Я в курсе что это нужно и важно, просто пока не успел обдумать как это все конвертить во вращения.

  8. Written by Knekker
    on 26 November 2010 at 10:49
    Permalink

    Whenever i try to source this script I keep getting a // Error: invalid directive // I’ve tried putting the script in every script folder there is in maya. What am i doing wrong? I use maya 2010 btw.

  9. Written by Sagroth
    on 26 November 2010 at 11:03
    Permalink

    Have you tried the latest .py version? I heard old .pyc caused problems on different OSes, so I’ve put .py eventually.

  10. Written by knekker
    on 26 November 2010 at 12:01
    Permalink

    Hey thanks for the quick reply, i figured out the problem, In the script editor i forgot to choose the Python menu before loading the script.

    Now I have loaded the script with no errors, it seems to have loaded just fine, now my question is… Shouldn’t there apear a GUI box whenever i load this script? cause nothing happens.

    Am i missing a step or something? Pardon my noobness, I’ve never loaded a python script before.

  11. Written by knekker
    on 26 November 2010 at 12:06
    Permalink

    Oh I forgot to mention that after i loaded the script I ran the “from sag_instancerToGeometry import *
    sag_instancerToGeometry()” lines, and a GUI box apears, but it only contains “Start from Current Frame” button.

    We are running linux here at the company, perhaps thats the reason, rest of the GUI is missing?

  12. Written by knekker
    on 26 November 2010 at 12:15
    Permalink

    well I guess you could just delete my posts, I got it to work now for some odd reason. = /

    Thanks for the help btw.

  13. Written by knekker
    on 26 November 2010 at 12:25
    Permalink

    This tool is really neat at creating objects that translates along with the instanced objects, my question now is… it is possible for it to simulate the rotation of each instanced object/particle as well?

  14. Written by Sagroth
    on 26 November 2010 at 22:56
    Permalink

    Good that everything is working eventually.

    Script bakes rotations, but from ‘Rotation’ channel only – no aims. There’s a mention about that in notes above. So, if you have it mapped – everything should be fine, if you use aims – you should try to convert them into rotations for baking or rotate baked objects afterward.

  15. Written by knekker
    on 29 November 2010 at 12:45
    Permalink

    Alright thanks alot for the tip Sagroth, very appreciated.

  16. Written by Yaleh
    on 15 December 2010 at 1:58
    Permalink

    Love the script. Thanks for putting it out there!

  17. Written by gardenia
    on 28 January 2011 at 21:22
    Permalink

    Your script works beautifully. Thank you so much for making it available. I very often have to create instances on a surface which is the goal of the particles. The instances Aim Direction is connected to Goal World Normal 0 PP so that they get oriented along the surface normal. Is there a way to transfer the instances orientation to the Rotation channel so that your script evaluates it?

    Thank you!

  18. Written by Sagroth
    on 28 January 2011 at 22:57
    Permalink

    Yeap, you just need to use your goalWorldNormal0PP instead of velocity in the angleBetween formula I wrote above. And I think goalWorldNormal0PP won’t get generated at birth, so put this script into runtime expression instead of creation.

  19. Written by gardenia
    on 31 January 2011 at 19:12
    Permalink

    Thanks so much Sagroth. It works great!!

  20. Written by Daniel
    on 28 February 2011 at 15:24
    Permalink

    Thanks a lot, It saved me quite a lot of time today 🙂

  21. Written by Malek
    on 21 April 2011 at 9:35
    Permalink

    you are a great person!!!

  22. Written by Mitch
    on 29 March 2012 at 5:38
    Permalink

    Thanks a million!
    I only needed a single frame baked, but when I checked out multi-frame baking all the frames except the final frame were keyed invisible for each instanced object.
    Another anomaly:
    On my first attempt, the baked instances didn’t match the Instancer. I found that one of the original meshes didn’t have it’s pivot at the origin. I moved it and centered the pivot, and then it worked.
    Very grateful.

  23. Written by Mitch
    on 29 March 2012 at 16:21
    Permalink

    A followup on the visibility issue:
    When I bake the particleInstancers, a visibility keyframe is added to the original geometry as well as all the baked instances. I’ve checked the geometry, instancers, and particles, and none have keyframes on visibility before I run your script…

  24. Written by Sagroth
    on 29 March 2012 at 18:51
    Permalink

    Thanks for the feedback. I’ve made a lot of improvements to the utility a long time ago already. A pack of issues were solved, maybe some of these as well. I’ve just forgotten to update it here – I’ll try to recheck the issues you’ve mentioned and make an update in a couple of days.

  25. Written by Alin
    on 5 April 2012 at 9:58
    Permalink

    thank man, very good script

  26. Written by Gino
    on 28 April 2012 at 22:25
    Permalink

    Hi,

    I’m testing the script now on a particle instancer… It’s been running for 10+ minutes now but I don’t see anything happing.. is the viewport updated during the process?.. I have 14000 particles on here so I’m thinking it might take a while but… Could you add a progressbar to this?
    Heh.. I should have tested this on a simpler Instancer 🙂

  27. Written by Sagroth
    on 29 April 2012 at 10:48
    Permalink

    Yeah, 14k seems to be too much 🙂

  28. Written by vvvvvvvvvv
    on 10 July 2012 at 9:17
    Permalink

    THANK YOU! beautiful script.

  29. Written by Brendan
    on 14 July 2012 at 8:48
    Permalink

    Thankyou so much, I was dreading using a GI/Final Gather solution for instanced light sources and this allowed me to bake a sim and attached a Geo Light shader to my geometry.
    Awesome!!!

  30. Written by matt richardson
    on 6 September 2012 at 16:34
    Permalink

    You are a god among men!!!!!!

  31. Written by Jamie
    on 2 October 2012 at 20:57
    Permalink

    Hey thanks… very useful.

  32. Written by matt
    on 11 October 2012 at 14:53
    Permalink

    thanks man, worked like a charm!

  33. Written by RP
    on 13 December 2012 at 6:47
    Permalink

    Спасибо за скрипт, очень пригодился 🙂

  34. Written by Jon
    on 30 December 2013 at 21:17
    Permalink

    Thanks so much for this script! For some reason, I keep hitting an “index out of range” error once it starts applying the transformations to the duplicated instance, around line 275. I’m on Maya 2014 and OSX Mavericks. Wondering if you have any pointers on what to do to fix this?

  35. Written by Jon
    on 3 January 2014 at 13:44
    Permalink

    Ah, disregard my last message, I got it figured out. Thanks again!

  36. Written by Sagroth
    on 6 January 2014 at 19:18
    Permalink

    No problems. If you’ve found an issue and the solution for it – let me know, please, and I will add that to the code.

  37. Written by HowardM
    on 18 January 2014 at 1:16
    Permalink

    Excellent! You are a master 😀

  38. Written by Shamus
    on 24 February 2014 at 3:34
    Permalink

    You saved me. It works flawlessly even on huge numbers of particles, you just have to be patient because python is not multi-threaded. Thank you very much for this script.

  39. Written by gerhard
    on 20 June 2014 at 15:00
    Permalink

    I would have loved to know how :
    “index out of range” error once it starts applying the transformations to the duplicated instance, around line 275
    got fixed as I am having the same problem. 🙁

  40. Written by camel
    on 19 July 2014 at 16:35
    Permalink

    Hello.
    I’ve tried your script – it works nice,
    but rotation of objects’ not match with original particles.
    I’ve tried on ball with pivot set to bottom vertex, instancer’s balls are rotating in different way than balls copied by script.
    Cheers

  41. Written by Sagroth
    on 21 July 2014 at 7:21
    Permalink

    There are some limitations to what you can use for rotation. Please, send maya scene to my email (see Contact page) and I’ll try to figure this out.

  42. Written by lidia
    on 12 October 2014 at 12:07
    Permalink

    Worked like a charm. I could convert my instanced particles to mesh in one frame.

  43. Written by kyran
    on 26 November 2014 at 14:40
    Permalink

    Works great unless you have a fair number of particles, Maya keeps seizing up for me – any ideas how to fix this? Great work though!

  44. Written by Tanja
    on 12 March 2015 at 14:31
    Permalink

    Hi!

    How do I download the plugin? When I click “Download”, a text document only opens with the script

    What am I doing wrong?

  45. Written by Kirill
    on 25 March 2015 at 5:25
    Permalink

    Really vital tool! Thank you so much.

  46. Written by tutumannyaque
    on 2 June 2015 at 14:46
    Permalink

    Wow! Thank you so much! You saved me hours of time!

  47. Written by Simon
    on 6 July 2015 at 16:19
    Permalink

    will this work with Maya 2016? I know Maya 2016 has a convert option but it appears to do nothing.

  48. Written by Wesley Wilson
    on 31 July 2015 at 16:08
    Permalink

    Great script! It’s very convenient and handy. However, I have noticed a problem when the geometry the instancer is calling to has namespaces. It crashes Maya and I don’t even get an error message. It just freezes up.

    I understand its easy to correct on the artist’s end, but some namespace interactivity would make this already useful tool more robust.

  49. Written by Theo
    on 11 March 2016 at 18:53
    Permalink

    Greetings! I’ve been trying to export an nParticles animation with an instancer to an FBX file in Maya 2016. The instancer is cycling a Sequential animation from 12 Instanced objects (meshes). I’m also using a custom scale expression to create random sizes. When I convert the instancer using your script and export it as an FBX file, only the first frame of the sequential cycle is visible. No per instance animation plays and all the instances are the same size. The motion of the particles however is perfect with the exception of the aim direction (I couldn’t manage to get your rotation script to work. Only one instance faced the attractor constantly). Your script is the closest I have come to getting this thing to actually work but I’m stuck and any help would be greatly appreciated. Thank you in advance for your time.

  50. Written by Sagroth
    on 21 March 2016 at 14:24
    Permalink

    Hi, Theo. This utility doesn’t understand aim rotation modes, only straight rotation values (had no patience yet to figure out every available scenario) – maybe that’s the problem in your case, you need to substitute your aim with rotations for that to work. Send me a simplified scene with your setup, please, and we’ll see what could be done.

Subscribe to comments via RSS

Leave a Reply