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.