Digital humans the art of the digital double
Ever wanted to know how digital doubles are created in the movie industry? This course will give you an insight into how it's done.
# 1 02-02-2017 , 01:26 PM
Registered User
Join Date: Feb 2017
Location: Glasgow, Scotland
Posts: 2

using mel to select multiple objects

i am trying to select a range of objects using mel. is this even possible?

for a uni project i am using ncloth to lay a cobblestone path (the path looks more natural when i do this) but when i delete the ncloth i am left with objects in two states, the initial and set. i can easily delete the duplicates but it is taking too long to do.

lets say my objects are called brick1-brick100, is there a way to select bricks 1-50 using mel? i know to select one object using select ("brick1*"); (or just select brick1 works also) - am i on the right track to selecting what i want?

# 2 11-02-2017 , 03:28 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
One way would be to use python list comprehensions. This will select brick 1 to 4. (Note that even though it says 1-5, 5 is not included)

Not the most efficient, but it will work.

Code:
python("cmds.select(['brick%s' % n for n in range(1,5)])");


Imagination is more important than knowledge.
# 3 29-01-2020 , 03:10 PM
Registered User
Join Date: Jan 2020
Posts: 7
So basically you want to run a for-loop x-number of times you want a brick to be selected. F.e. you want to select 50 bricks
$i start , <51 end
for($i=1; $i < 51); $i++)
{
}

inside the loop you check if there is an object with the name "brick"+"current run number"
if there is an object with that name you add it to selection.
if you reach maximum number of loopruns or an object with the name you looking for doesn't exist you end the loop

I am at work and can't look up the syntax at the moment but that's one solution for it basically.

Hope that helps user added image


Last edited by AverageRigger; 29-01-2020 at 03:25 PM.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads