ScriptSpot

Forum topic · General Scripting

do something based on object name prefix

By mjbg · 2011-08-17

Description

hello

i´m struggling with some basic concepts lately

what i am trying to do is do something based on the object name prefix..
i am trying something like this:

for o in selection as array do if o.name == 'Box'* do print "it works!"

but the * dosnt work with the == signal i i think

any help on this is greatly apreciated

Comments (2)

Pathname Literals

Anubis · 2011-08-17

Search in the mxs-help for "Pathname Literals" topic. For ex.:

$*box*

- will collect all objects with 'box' (at any place) of their names, like: "the_box01", "boxer", etc., while

$box*

will collect all with prefix (starting with) 'box' name.

objs = $box* as array
for obj in objs do print obj.name

For more precision tests check

matchPattern()

function.

Cheers!

mjbg · 2011-08-17

Thank you Anubis..

i belive matchPattern is what i wanted

for o in selection as array do if (matchPattern o.name Pattern:"*Box*") == true do print "it works!"