[Closed] Loop through objects, set visibility
--select all objects, set visibility to 0
(
Objs = for o in objects collect o
for o in Objs do
(
--set random 30 frame interval to keyframe visibility 'on' within a 300 frame animation
)
)
What I am looking to do is have all of these objects (hundreds) sort of build themselves as the animation progresses. Can someone help get me started on the script?
holy crap I did it!! It’s a total hack job mind you but it works!
(
Objs = for o in objects collect o
for o in Objs do
(
		myNum = random 1 500
		my2ndNum = myNum+10
		print myNum
		o.visibility = bezier_float() -- Track View: Add Visibility Track
		addNewKey o.visibility.controller myNum #select
		addNewKey o.visibility.controller my2ndNum #select
		o.visibility.controller.keys[1].value = 0
		o.visibility.controller.keys[2].value = 1
		--actionMan.executeAction 0 "40022"
)
)
                      You can simplify it by saying
for o in objects do
Collecting the objects first and then looping through them is a good practice only if you intend to modify the scene by adding or deleting objects inside the loop. In that case, you could also say
Objs = objects as array
for o in Objs do ...
Your code is not wrong though, just a bit wordy
Thanks Bobo!
Sadly this doesn’t work with MR. So what I need to do now is set the visibilty in the object properties not the dope sheet. Here is what I have. It will set the object properties to 0 for both keys but it should be setting the second key to 1. What am I doing wrong?
(
 Objs = objects as array
 for o in Objs do
 (
 print [o.name]( http://o.name/)  
 myNum = random 1 300
 my2ndNum = myNum+20
 
 set animate on
 --actionMan.executeAction 0 "40022"
  sliderTime = myNum
 o.visibility = 0
 sliderTime = my2ndNum
 --actionMan.executeAction 0 "40022"  -- Edit: Properties
 o.visibility = 1
 --actionMan.executeAction 0 "50048"  -- Tools: Material Editor Toggle
  o.material = meditMaterials[2]
 )
 )