I’m extending a Ruby script I wrote for personal use some years ago. It adds a menu to insert a selected Dynamic Component, using
if (myComponent !=0)
Sketchup.active_model.place_component myComponent, false
end
How can I make sure either that the Dynamic Component Options window is open already, or open it if it isn’t?
I can get a ‘handle’ on it using (from the Ruby API) UI.menu method
myMenu = UI.menu("Window/Component Options")
but I can’t see a method either to display it, or to check if it is already displayed.
I’ve looked in the API docs for Methods called Show or Display, but they don’t seem to apply to Window objects.
And this Window doesn’t appear in the list of Inspectors, Pages, or Toolbars so I can’t use UI.show_inspector or UI.show_preferences. I could just display the Dynamic Component toolbar, but I really want to open the Component Options window.
Is what I want to do possible? If so, how, if anyone can point me in the right direction to work it out, or show me an example.
PS. I experimented in the Ruby Console after getting myMenu.
myMenu.show
myMenu.open
both give errors, and when i list the methods, I don’t see one that would do what I want (scroll sideways to see them all):
> myMenu.methods
[:add_item, :set_validation_proc, :add_separator, :add_submenu, :to_json, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :extend, :display, :method, :public_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]
.display and .inspect both just return the object ID.
PPS: AHA!. A broader Google search showed up an old Sketchucation Forum post that I hadn’t found before:
http://sketchucation.com/forums/viewtopic.php?f=180&t=44548
The key line is:
$dc_observers.get_latest_class().show_configure_dialog()
Now who would have thought of that, reading the API docs?
And thanks in advance to @DanRathbun, who provided the original answer.