Notifications
Clear all

[Closed] help with array

Hi there
i try animate some objects beaed on time array and array of position this is a very simple example

---------------------------------
  teapot radius:10 pos:[0,0,0]
  timeAr = #("0","5","10")		--3
  poseAr=#([-60,0,30],[-30,0,12],[0,0,0]) --3 pose
  Ar1integer=for i in timeAr collect (i as integer)	
  appenar=#()
  append appenar Ar1integer
  append appenar poseAr 
  
  for i =1 to appenar[1].count do
  	(
  	with animate on 
  	(
  	j=appenar[1][i]	
  	slidertime =j
  	k=appenar[2][i]	
  	($teapot001.pos=k)
  	)	
  )
  ------------------------------------

and my question is, is it possible to rewrite this script when we have a list of objects instead of one object and multidimensional array instead of an array

listobj=#($Teapot001,$Teapot002, $Teapot003, $Teapot004)
  poseAr2=#(#([-60,0,30],[-30,0,12],[0,0,0],[30,0,12]),#([0,0,0],[0,0,0],[0,0,0],[0,0,0]),#([0,0,0],[0,0,25],[0,0,50],[0,0,75])

any help is so appreciated
Thanks in advance

1 Reply

i put the answer maybe helpful for someone, it was a good practice for me

-----------
   --list of our objects
   lis_obj = for k=0 to 3 collect teapot radius:10 pos:[k*30,0,0]
   --gathered position or transform
   poseAr=#(#([-60,0,30],[-30,0,12],[0,0,0],[30,0,12]),#([0,0,0],[0,0,0],[0,0,0],[0,0,0]),#([0,0,0],[0,0,25],[0,0,50],[0,0,75]))
   --defined key to be anomated
   listPose_frame = #("10","20","30")	  
   
   --The poseAr is a multidimensional array so to put the multidimwnsional array into simple array	
   for i = 1 to poseAr.count do (execute (("Pose_" +i as string)+" ="+(poseAr[i] as string)))	
   --collect all poses
   Total_pos=for i=1 to poseAr.count collect ("Pose_"+i as string)	
   TimeArinteger=for i in listPose_frame collect (i as integer)
  	 
  	 
   --now i connect this 3 arrays together
   for k=1 to TimeArinteger.count do for i=1 to lis_obj.count do for j=1 to Total_pos.count do
  	 (
  		 with animate on 
  		 (
  		 kk=TimeArinteger[k]
  		 slidertime =kk	
  		 lis_obj[i].pos = ((execute Total_pos[k])[i])
  		 )
  	 )
   --------------
  Thanks God