Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

to make a spline in the middle of the box

anycganycgJ8A6A
Advocate

to make a spline in the middle of the box

anycganycgJ8A6A
Advocate
Advocate

 

hi 
always thank you for good answer
i need some help
Can you see the attached file Code like this is too difficult for me I need help from experts Is this possible with a script?
0 Likes
Reply
Accepted solutions (1)
620 Views
4 Replies
Replies (4)

anycganycgJ8A6A
Advocate
Advocate

sorry  new max file 

 

0 Likes

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

something like this (quick and dirty):

 

mapped fn createMiddleSpline node = 
(
	tm = node.transform
	bb = nodeGetBoundingBox node tm
	
	x = abs (bb[2].x - bb[1].x)
	y = abs (bb[2].y - bb[1].y)
	z = abs (bb[2].z - bb[1].z)
	
	xx = #(x, y, z)
	ss = #(x, y, z)
	sort ss
	
	i = finditem xx ss[2]
	k = finditem xx ss[3]
	
	if (i < k) do swap ss[2] ss[3]
	
	
	rect = rectangle name:(node.name + "_sp") width:ss[3] length:ss[2] transform:tm wirecolor:(node.wirecolor * 0.6) parent:node 
	rect.center = node.center
	
	n = finditem xx ss[1]
	
	in coordsys tm
	(
		case n of
		(
			1: rotate rect (eulerangles 90 0 90) 
			2: rotate rect (eulerangles 90 0 0) 
		  --3: rotate rect (eulerangles 0 0 0)
		)
	)
	
	converttosplineshape rect 
	rect
)

createMiddleSpline $
0 Likes

denisT.MaxDoctor
Advisor
Advisor
mapped fn createMiddleSpline node = 
(
	tm = node.transform
	bb = nodeGetBoundingBox node tm
	
	x = abs (bb[2].x - bb[1].x)
	y = abs (bb[2].y - bb[1].y)
	z = abs (bb[2].z - bb[1].z)
	
	xx = #(x, y, z)
	ss = #(x, y, z)
	sort ss
	
	i = finditem xx ss[2]
	k = finditem xx ss[3]
	
	if (i < k) do swap ss[2] ss[3]
	
	
	rect = rectangle name:(node.name + "_sp") width:ss[3] length:ss[2] transform:tm wirecolor:(node.wirecolor * 0.6) parent:node 
	rect.center = node.center
	
	n = finditem xx ss[1]
	
	in coordsys tm
	(
		case n of
		(
			1: rotate rect (eulerangles 90 0 90) 
			2: rotate rect (eulerangles -90 0 0) 
		  --3: rotate rect (eulerangles 0 0 0)
		)
	)
	--format "% % % >> % >> %\n" x y z ss (finditem xx ss[1])
	
	converttosplineshape rect 
	rect
)

delete objects 

bb = for k=1 to 10 collect 
(
	box width:(random 10 100) length:(random 10 100) height:(random 10 100) \
		pos:(random -[100,100,100] [100,100,100]) rotation:(eulerangles (random 0 180) (random 0 180) (random 0 180)) \
		wirecolor:(random white black)
)
	

createMiddleSpline bb
0 Likes

anycganycgJ8A6A
Advocate
Advocate

very very  thank you

always  perpect answer

you are genius

really really thank you

0 Likes