ScriptSpot

Forum topic · General Scripting

checking if objects already exist

By gramx · 2010-12-18

Description

Hi

I have created a camera rig script, which sets up a rigged camera in your max scene!

What I am also trying to do is check before it creates the rig to see if any cameras already exist. If they do exist then find the highest numbered Camera prefix and increment it. eg If camera01_ and camera02_ already exist then I will use a camera03_ prefix.

I am stuggling to do this part of the script.

Any help would be very appreciated.

Thanks

gram

Comments (3)

gramx · 2010-12-19

Thanks Anubis, Thats exactly what I was trying to do!

Graph, I will have a look at the uniquename and matchpattern functions also, they might come in usefull too.

Cheers

Gram

here is...

Anubis · 2010-12-18


-- collect the names of all cameras:
cams = for c in cameras where
    classOf c != Targetobject collect c.name

-- var #1 -
sort cams -- sort array
myCam = getNodeByName cams[cams.count]

-- var #2
myCam = getNodeByName (amax cams)

Cheers

Graph · 2010-12-18

did you look into the uniquename and/or matchpattern functions?