Ruby access to photo match image?
-
I'm interested in creating new ways to match photos in Sketchup 7. Does anyone here know how to access the photo image created with "File->Import->Use as new matched photo" from ruby?
The photo does not appear to be part of the model. See for yourself:
- Load a new matched photo into an empty model.
- Open the ruby console "Window->Ruby Console"
- Type
Sketchup.active_model.entities.length
The answer is 0 (zero), suggesting that the photo is not a geometric part of the model.
The photo appears to be associated with the scene tab. In ruby the scene tab is a Page object. I don't see anything in the possibly obsolete ruby API docs for Page that suggests access to a photo image. To double check, I tried to take advantage of ruby's introspection methods.
page = Sketchup.active_model.pages[0] page.methods
yields
@unknownuser said:
["to_a", "set_attribute", "instance_eval", "typename", "add_observer", "type", "protected_methods", "style", "extend", "use_camera?", "use_hidden=", "eql?", "instance_variable_set", "is_a?", "hash", "to_s", "get_attribute", "valid?", "remove_observer", "use_style?", "use_camera=", "camera", "class", "tainted?", "private_methods", "parent", "hidden_entities", "untaint", "use_style=", "description", "deleted?", "use_hidden_layers?", "id", "label", "inspect", "attribute_dictionary", "delete_attribute", "description=", "layers", "clone", "public_methods", "use_axes?", "use_hidden_layers=", "transition_time", "model", "freeze", "display", "respond_to?", "id", "transition_time=", "methods", "==", "method", "use_shadow_info?", "use_axes=", "===", "nil?", "dup", "instance_variables", "instance_of?", "delay_time", "rendering_options", "send", "attribute_dictionaries", "name", "update", "use_rendering_options?", "entityID", "use_shadow_info=", "use_section_planes?", "delay_time=", "object_id", "name=", "=~", "singleton_methods", "send", "equal?", "taint", "use_rendering_options=", "frozen?", "instance_variable_get", "use_hidden?", "use_section_planes=", "set_visibility", "shadow_info", "kind_of?"]
That's probably too much to digest; I don't see anything like "watermark_image" there. I wish ruby had the same sort of baked in API documentation that python has, so we wouldn't have to rely on our overworked Sketchup heroes to publish API documentation for us. But no. Like most other languages, ruby API documentation is in the comments, and thus unavailable from the run time environment.
OK. So it's not in the model, and its not in the Scene/Page. Perhaps it is in the Style.
Sketchup.active_model.styles[0].methods
@unknownuser said:
["to_a", "set_attribute", "instance_eval", "typename", "add_observer", "type", "protected_methods", "extend", "eql?", "instance_variable_set", "is_a?", "hash", "to_s", "get_attribute", "valid?", "remove_observer", "class", "tainted?", "private_methods", "parent", "untaint", "description", "deleted?", "id", "inspect", "attribute_dictionary", "delete_attribute", "description=", "clone", "public_methods", "model", "freeze", "display", "respond_to?", "id", "methods", "==", "method", "===", "nil?", "dup", "instance_variables", "instance_of?", "send", "attribute_dictionaries", "name", "entityID", "object_id", "name=", "=~", "singleton_methods", "send", "equal?", "taint", "frozen?", "instance_variable_get", "kind_of?"]
I don't see anything suggestive there either.
Suggestions for new avenues of investigation are much appreciated.
-
I also would like to see control over photo-match in Ruby and ability to read position of a 'cropped' camera view. I am afraid there is none for the time being.
Tomasz
-
The photo image appears to be displayed using some display primitives that are not available from the Ruby API.
The Watermark image can be toggled from the
rendering_options["DisplayWatermark"]
option, but toggling it has no effect on the Photomatch image.If you use the image as an "Image", then you will have total control over it - position, scale, transparency, visibility, etc. That may actually work in your favor.
-
@jim said:
If you use the image as an "Image", then you will have total control over it - position, scale, transparency, visibility, etc. That may actually work in your favor.
Nice work Jim testing out that DisplayWatermark option to show that the match photo image is something special.
I intend to use an Image object for exactly the reasons you say. It would have been nice to construct it from a match photo image though. My vision of my new workflow is to use the existing Match Photo tool to get an initial alignment for an image with a model. Then use my new tool to refine the image alignment. It will seem hokey when I have to ask the user "could you please load that same image you loaded before for me now, with this other tool?".
-
sorry hope im not hijacking but this has been bugging me about photomatch, you can't match a photo that has been corrected to 2 point perspective, and if u can't control the photo through the API can u control the guiding lines? like is the any way to lock the blue axis in a vertical possition to force it into 2 point?
Advertisement