View Full Version : testing if object selected??
10-31-2005, 05:15 AM
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.
10-31-2005, 05:24 AM
Maybe this does what you need:
if selection.count != 0 do --STUFF
10-31-2005, 05:36 AM
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.
10-31-2005, 05:43 AM
You can use this to see if a camera is selected:
If (selection.count != 0) and (superClassOf selection == camera) do --STUFF
Or do you want to know the type of the camera as in free/target?
10-31-2005, 06:11 AM
thanks light! that did the trick :cool:
here is the script i ended up with
If ($.name == "Camera01") and (superClassOf selection == 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.
10-31-2005, 06:44 AM
You want the name of the camera to be Camera01 only?
10-31-2005, 07:20 AM
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 :D
10-31-2005, 07:28 AM
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.
10-31-2005, 07:35 AM
local arr = #(#("Camera01", "Camera02", "Camera03", "Camera04"), #(#(0, 100), #(101, 200), #(201, 300), #(301, 400)))
local theVal = arr[findItem arr selection.name]; animationRange = interval theVal theVal
10-31-2005, 07:59 AM
thanks light, 2 lines sure beats 20 :D
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. :thumbsup: :applause:
10-31-2005, 10:12 AM
Hey glad it helped! :thumbsup:
I will try to write another one using the first technique.
10-31-2005, 10:12 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.