Explode maxscript problem

Explode maxscript problem

Anonymous
Not applicable
2,234 Views
9 Replies
Message 1 of 10

Explode maxscript problem

Anonymous
Not applicable

Hello,

 

Situation: I have a base box and four more boxes of different sizes, which I want to explode them outside the base with 100 mm.

 

Like so:

 

explode.png

 

I tried this way, but it's not what it takes.

 

--select all boxes
select $*

 

--explode

for selObjs in selection do
(
selObjs.pos.x = (selObjs.position.x + 100)
selObjs.pos.y = (selObjs.position.y + 100)
selObjs.pos.z = (selObjs.position.z + 100)
)
)

 

Here is the code for boxes:

 

--boxes
box_1 = box length:500 width:500 height:500
box_1.pos = [0,0,0]
---
box_2 = box length:500 width:500 height:100
box_2.pos = [0,0,-100]
---
box_3 = box length:500 width:500 height:100
box_3.pos = [0,0,500]
---
box_4 = box length:500 width:100 height:500
box_4.pos = [-300,0,0]
---
box_5 = instance box_4 -- Atention, this is an instance !
--box_5.pos = [300,0,0]
box_5.pos = [300,0,0]

 

 

Maybe you have any idea how this can be done ? Please !

 

 

0 Likes
2,235 Views
9 Replies
Replies (9)
Message 2 of 10

Swordslayer
Advisor
Advisor
(
	local base = box length:500 width:500 height:500 pos:[0,0,0]
	local boxes = #(
		box_1 = box length:500 width:500 height:100 pos:[0,0,-100],
		box_2 = instance box_1 pos:[0,0,500],
		box_3 = box length:500 width:100 height:500 pos:[-300,0,0],
		box_4 = instance box_3 pos:[300,0,0]
	)

	local offset = 100
	for b in boxes do move b (normalize (b.center - base.center) * offset)
)
Message 3 of 10

Anonymous
Not applicable

 

 

 

 

 

--select all boxes from max scene
select $*


--offset
offset = 100


--explode

--for b in boxes do move b (normalize (b.center - base.center) * offset)

 

for selObjs in selection do
(
move selObjs (normalize (selObjs.center) * offset) -- this is a start, but is not really OK, "base box" must remain in place
)

 

 

 

 

 

 

 

0 Likes
Message 4 of 10

Swordslayer
Advisor
Advisor

Well, then don't select everything (actually don't select anything, it's better to manipulate objects without selecting them), for example if the center box name is CenterBox, you can use $CenterBox.center as the reference point and iterate for b in $box* 

Message 5 of 10

Anonymous
Not applicable

Thanks again, 

 

A few important things:

 

 

 

 

 

 

 

 

Outside boxes are in place, but the middle one is not.

Something is missing.

0 Likes
Message 6 of 10

Swordslayer
Advisor
Advisor

I strongly recommend you watch the whole maxscript 101 series, it's hard to give you any advice since you always fall back to your assumptions, and the assumptions are wrong.

0 Likes
Message 7 of 10

Anonymous
Not applicable

Hello,

 

My intention was not to hurt your feelings.

 

My "assumptions" are based on the results.

 

This:

for b in $box* do move b (normalize (b.center - $CenterBox.center) * offset)

 

Or this:

for b in $* do move b (normalize (b.center - $.center) * offset)

 

Have the same result, in my case. And the result is not what I want.

 

Maybe I did something wrong.

 

However, I'm glad you didn't send me to do any programming academy and you gave me "only" to read/watch Maxscript 101. Smiley Tongue

0 Likes
Message 8 of 10

Swordslayer
Advisor
Advisor

@Anonymous wrote:

My "assumptions" are based on the results.

 

This:

for b in $box* do move b (normalize (b.center - $CenterBox.center) * offset)

 

Or this:

for b in $* do move b (normalize (b.center - $.center) * offset)

 

Have the same result, in my case. And the result is not what I want.


In that one particular case, the result will be the same but the inputs are different and the reason why they are different and in what they're different from the code I posted is also the reason it breaks for you when you change it like that. The fundamentals are best explained in the vids I linked - after you go through them, you will see what I mean.

0 Likes
Message 9 of 10

Anonymous
Not applicable

0 Likes
Message 10 of 10

Swordslayer
Advisor
Advisor

If that's the case, show what's the actual thing that you want to do, what are the constraints, in what way it will be used and how.

I already posted the solution for the original post, and it seems it wasn't what you wanted.

 

Alternatively, use an existing script like Exploded View Generator.

0 Likes