ScriptSpot

Forum topic · Scripts Wanted

Render objects one at a time alphabetically

By bb3d · 2014-11-20

Description

Hi folks Here's my situation: We have to create 160 images of apartment icons for a website which show the location of the appartment in the building.

Example: (Hover over the apartments list)

http://www.leutschentower.ch/wohnen/was/wohnungen.html

Now, I really don't feel like unhiding every apartment seperatly and render it out, so I wanted to write a script for that.

I managed to set the objects visible each at another frame by script, so that I can render it out as an animation:

-----------

allObj = $
t = 5;

for obj in allObj do
(
t = t+1;
t0 = t-1;
t2 = t+1;
with animate on
(
at time t0 obj.visibility.controller.value = 0.0
at time t obj.visibility.controller.value = 1
at time t2 obj.visibility.controller.value = 0.0
)

)

-----------

(I am a beginner, as you may see ;)

But now the object's visibility is not sorted alphabetically and that gives me much work in the post when I have to rename every single rendered image.

How can I now loop through the objects alphabetically?

Or

How can I render the scene giving the image the name of the object currently visible?

Thanks for your help, I hugely look up to you experienced scripting guys!

Comments (1)

.

miauu · 2014-11-21

Sort objects by name:


function SortByName obj01 obj02 = 
(
     striCmp obj01.name obj02.name
) 
allObjsArr = $
collect obj
qSort allObjsArr SortByNames
-- print to see if the objects are sorted by name
print allObjsArr 
-- if they are sorted, you can continue with the rest of your script.