Camera API not working properly?
-
Hi,
I am testing some code with camera and things are not working, here is example of just one of many;
camera = Sketchup;;Camera.new status = camera.perspective? if (status) UI.messagebox "Perspective" else UI.messagebox "Orthographic" end
It always says its on Perspective even when its not.
Other examples found here doesn't work as well.. http://www.sketchup.com/intl/en/developer/docs/ourdoc/camera.php#perspective?
I am using Ruby Code Editor to test this code...Any ideas on what is wrong here?
-
That worked..thank you very much!
-
Yeah, you're not actually testing the state oft he current camera being used in the model, your testing the state of a new camera object - Sketchup::Camera.new. And it looks like new cameras default to perspective. Instead, try this:
camera = Sketchup.active_model.active_view.camera
status = camera.perspective?
if (status)
UI.messagebox "Perspective"
else
UI.messagebox "Orthographic"
end -
I do see that what you put there is taken verbatim from the API..... what can I say, oops! We'll need to upgrade those examples.
-
@chris fullmer said:
I do see that what you put there is taken verbatim from the API..... what can I say, oops! We'll need to upgrade those examples.
And many more. cough #typename cough
-
Hi,
I require some help again.
I can't get the following code to do;
-
Change current scene from "Perspective" to "Orthographic". <--This is done fine
-
Update current page and preserve "Orthographic" camera. <--The code changes from Persp to Ortho but when I click on page again it changes back to Persp.
How can I solve this?
model = Sketchup.active_model ; pages = model.pages ; page = pages.selected_page camera = Sketchup.active_model.active_view.camera ; status = camera.perspective? ; if (status) Sketchup.send_action(CMD_VIEW_PERSPECTIVE) ; end ; page.update(1) ;
Again thanks for the help!
-
-
model = Sketchup.active_model camera = model.active_view.camera camera.perspective = false model.pages.selected_page.update(1)
-
Thanks it worked!
Advertisement