[Closed] testing if object selected??
I cant seem to figure this out, i thought it was simple but i just cant figure it out :shrug:
what im trying to test is if an object is selected then do somthing.
for example: if selection = camera01 do
Thanks for any help, probably a simple answer just cant seem to find it anwhere in the help.
Richard,
Maybe this does what you need:
if selection.count != 0 do –STUFF
Light
thanks light, but i probably should have been a bit more specific with my question.
I want to test what camera is selected (if any at all), then set the range of the timeslider to the range of that scene for the selected camera.
I can set the timeslider with the, animationrange = interval 10 500. for example.
just cant figure out how to test what camera is selected.
thanks.
You can use this to see if a camera is selected:
If (selection.count != 0) and (superClassOf selection[1] == camera) do –STUFF
Or do you want to know the type of the camera as in free/target?
Light
thanks light! that did the trick
here is the script i ended up with
If ($.name == “Camera01”) and (superClassOf selection[1] == camera) do animationRange = interval 4 55
then ill just repeat the above code for the different cameras in the scene, probably not the most efficiant way to do it but it works.
well i think so? because i only want to set the animationRange to thoes values when camera01 is selected. if camera02 was selected then the animationRange values would be somthing different.
basically what i want this script to do is, if i have a camera selected, say the camera for shot 8 of the animation. I then want the timeslider to adjust to the animationRange that shot 8 runs for, say fram 200 to 450. or if shot 4 camera was selected then the animationRange might be 100 to 140.
All this script does is saves me time when doing renders and preview renders, as i dont have to remember the frames that each shot went for, i just select the camera i want to do a preview render of , run the script, then do the preview render.
There is probably a better way to do it, with variables or somthing like that. But if i set variables to the animationRange values, or the cameras i still have to have have lots of the above if statements dont I? it would not really shorten the code at all?
Because atm my script is just like 20 of the above if statements in a row
The best way would be a script that would automatically set current animation range to camera’s animated range.
The simpliest way would be to create an array for camera names and ranges, which would be 2 lines.
I will try to write one for you.
Light
Simpliest one:
local arr = #(#("Camera01", "Camera02", "Camera03", "Camera04"), #(#(0, 100), #(101, 200), #(201, 300), #(301, 400)))
local theVal = arr[2][findItem arr[1] selection[1].name]; animationRange = interval theVal[1] theVal[2]
Light
thanks light, 2 lines sure beats 20
I think i sorta understand it, You set 1 array that has all the camera names in 1 part, then in the second part of the array you set the ranges.
Then you made anoter array that finds the values in the second part of the first array according to the camera name selected, and then sets the animationRange to theses values in theVal array.
Thanks again Light. :applause: