ScriptSpot

Forum topic · General Scripting

- Linking relative objects -

By MrZmapping · 2009-11-30

Description

Hi everyone,

Im very new to scripting in max script, as of today!

I am trying to solve a problem that is starting to really bug me, and would make my work flow much quicker.

Could any of you suggest or provide insight or a script that could do the following?

I have 3 groups of objects

Bus_Graphic_01 - Bus_Graphic_110
Bus_Collider_01 - Bus_Collider_110
Bus_Controller_01 - Bus_Controller_110

What I need to do is LINK the objects in the group to the objects in the other groups by their numerical suffix, i.e.

Bus_Controller_01
--> Bus_Collider_01
-->Bus_Graphic_01

Bus_Controller_02
--> Bus_Collider_02
--> Bus_Graphic_02

....

Bus_Controller_110
--> Bus_Collider_110
--> Bus_Graphic_110

Could anyone give me some pointers or even a script (could be paid for) That could do this for me?

Any help would be greatly greatly appreciated!

Kind regards

Chris Bolton

Comments (3)

there you go ... g1 =

Anubis · 2009-12-01

there you go ...

g1 = $Bus_Controller_* as array
g2 = $Bus_Collider_* as array
g3 = $Bus_Graphic_* as array
-- link Bus_Graphic to the Bus_Collider
for i=1 to g3.count do g3[i].parent = g2[i]
-- link Bus_Collider to the Bus_Controller
for i=1 to g2.count do g2[i].parent = g1[i]

example code: -- collect

Anubis · 2009-11-30

example code:

-- collect 'em	
g1 = $Bus_Controller_* as array
g2 = $Bus_Collider_* as array
g3 = $Bus_Graphic_* as array
-- LINK
for i=1 to g1.count do g2[i].parent = g3[i].parent = g1[i]

result:

MrZmapping · 2009-12-01

Hiya,

Thankyou very much for the script! How can I adjust it so that the Bus_Graphic links to the Bus_Collider, and then the Bus_Collider links to the Bus_Controller?

Regards

Chris