Notifications
Clear all

[Closed] link object on path constraint to cylinder rotation

hi all … since my question changed quite a lot, i decided to open up a new thread.

as i was quite unclear in my last explainations, but advancing in the topic your replys helped me to get along. the idea that i had just would not work the way i thought.

to be more precise i set up a max file, which u can download here.

in the scene exists a cylinder that is rotating “Cylinder01” and there is a spline “Circle01” and a self modeled object represented by “Box01”.

i want to achieve that an array of the self modeled objects (for the moment at least one) move in on the spline (path constraint) according to the rotation of the cylinder.


pathConst = Path_Constraint()
pathConst.appendTarget $Circle01 100.0
pathConst.follow = true
  
ctrl = float_script()
  
sphereArray = #()
for i = 1 to 1 do (
  b = box() -- would like to replace box with $Box01, how?
  b.position.controller = pathConst
  deletekeys b.position.controller #allKeys
  b.position.controller.percent.controller = ctrl
  append sphereArray b
)
  
ctrl.AddNode "cyl" $Cylinder01
ctrl.script = "cyl.rotation.z_rotation" -- values are quite weird
-- 0 > 180 skip to -180 > 0, how to handle them?

thanks and best regards
thomas aka taemon

1 Reply

i’m finally done and have a script that is quite ok for me now.

a demoscene file u can find at www.shades-noir.at/dwl/foerderband_sphere.max

the script looks like this:


numberofTiles = 20
pathArray = #()
ctrlArray = #()

fn creatPathConst = (
	pathConst = Path_Constraint()
	pathConst.appendTarget $Circle01 100.0
	pathConst.follow = true
	append pathArray pathConst
)

fn creatCtrl abweichung = (
	abweichung /= numberofTiles
	ctrl = float_script()
	ctrl.AddNode "cyl" $Cylinder01
	ctrl.AddConstant "add" abweichung
	ctrl.AddConstant "len" 536.417
	ctrl.script = "(cyl.rotation.controller.'Z_Rotation'/360)*(pi*2*cyl.radius/len)+add"
	append ctrlArray ctrl
)

fn creatObj counter = (
	s = instance $Tile
	s.position.controller = pathArray[counter]
	s.position.controller.percent.controller = ctrlArray[counter]
)

for i = 1 to numberOfTiles do (
	j = i
	k = i as float
	creatPathConst()
	creatCtrl k
	creatObj j
)

cu Thomas aka taemon