How to link multiple objects to other objects?

Hi,

I've been struggling to find a way to link multiple objects in a selection or array to other multiple objects in another array or selection in a specific order.

Example:

Take Selection/array 01 (includes 200 objects box001, box0002 etc..) and link each item

to Selection 02 (Sphere001, Sphere002 etc..) by name or by order. ex. Box001 links to Sphere001 Box 002 links to Sphere002 and so on.

Another way that could work for me is to have point helpers created in order of selection or array onto each of these boxes above and have those helpers get linked to the corresponding boxes.

Example:

Create point helper 001 and link it to Box001, create point helper 002 and link it to box 002 etc..

Can someone please provide me with a quick example to learn from, many thanks!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

Note that the script collects the objects automatically, so the order of the manual selection(of the objects) is not used.

(
	--	"use this"
	pointsArr = $Point*
	dummysArr = $Dummy*
 
	--	"or this to collect the objects"
-- 	pointsArr = #()
-- 	dummysArr = #()
 
-- 	for o in objects do
-- 	(
-- 		if matchPattern o.name pattern:"Point*" do append pointsArr o
-- 		if matchPattern o.name pattern:"Dummy*" do append dummysArr o
-- 	)
 
	print pointsArr
	print dummysArr
 
	n = amin pointsArr.count dummysArr.count
	for p = 1 to n do
	(
		pointsArr[p].parent = dummysArr[p]
	)
)
miauu's picture

.

-- create a point and a box 
p = point()
b = box()
 
-- link p to b
p.parent = b
William_09's picture

Hello Miauu! Nice having you

Hello Miauu! Nice having you reply to me here, I appreciate your work in maxscript!

Sadly this is not what i'm looking for.

Your script creates only one point and one box and links them together, what I want:

I already have objects in my scene and I want to link them together in an orderly fashion.

Example:

Scene contains: Pt1, Pt2,Pt3,Pt4, etc..
and Dummy01, dummy02, dummy 03, etc..

I want to tell the script select all objects starting with name $Pt* and then select all objects with name $Dummy*

Link them together each while going through a loop or array. in an orderly format taking into consideration the order of selection.

So result is

PT01 links to Dummy01
pt02 links to dummy02
etc..

Thanks in advance!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.