I have a script I'm working on where I'm trying to iterate through scenes/pages and look for faces parallel to the camera for each scene. I have the code to iterate through faces and test to see if parallel to the camera, but I could find a way to grab the camera for other scenes to iterate my tests across all scenes.
I suppose I can change to each scene and then get current camera view, but I would think I should be able to grab the camera from a scene without having to change to that scene. Keep in mind, I don't know the scene names.
edited content below
OK, I solved my problem, here is a piece of the code.
# draft script - David Goldwasser
# find faces parallel to camera and draw lines back to camera
model = Sketchup.active_model
entities = model.active_entities
pages = model.pages
faces = []
entities.each do |n|
faces.push n if n.is_a? Sketchup;;Face
end
pages.each do |page|
camera = page.camera
eye = camera.eye
faces.each do |face|
status = camera.direction.parallel? face.normal
if status then
edges = face.edges
edges.each do |edge|
pts = []
pts [0] = eye
pts[1] = edge.start.position
pts[2] = edge.end.position
face = entities.add_face pts
end
else
end
end
end
The pages.each do is where I was having problems before. I was actually switching to that page and then getting current view, camera etc. But the animation was causing problems, so I had to have a dummy UI.messagebox to get it to behave. Now I don't and it is much cleaner.
So I have an edges.each nested in a faces.each, nested in a pages.each. My indentation for isn't so clear when previewed here.