# How to display Window/Component Options from Ruby?

**URL:** <https://forums.sketchup.com/t/how-to-display-window-component-options-from-ruby/23448>\
**Category:** Extensions\
**Created:** [April 11, 2016, 8:15pm UTC](https://forums.sketchup.com/t/how-to-display-window-component-options-from-ruby/23448 "2016-04-11T20:15:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [April 11, 2016, 8:15pm UTC](https://forums.sketchup.com/t/how-to-display-window-component-options-from-ruby/23448/1 "2016-04-11T20:15:48Z")

</div>

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

```auto
  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

```auto
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.

```auto
  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):

```auto
> 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](http://sketchucation.com/forums/viewtopic.php?f=180&t=44548)

The key line is:

```auto
$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.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [April 11, 2016, 9:10pm UTC](https://forums.sketchup.com/t/how-to-display-window-component-options-from-ruby/23448/2 "2016-04-11T21:10:47Z")

</div>

> [@john\_mcclenahan](#):
>
> 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.

It is a **`UI::WebDialog`** instance object. (The entire Dynamic Components extension is a Ruby extension.)

> [@john\_mcclenahan](#):
>
> I could just display the Dynamic Component toolbar, but I really want to open the Component Options window.

The toolbar itself is a **`UI::Toolbar`** instance object (not a native toolbar.) And although there is a iterator method to get ahold of the **`UI::Command`** objects attached to the toolbars, there is no getter method to get the command’s proc objects.

- **EDIT** (2022-08-16): Access to command [`proc`](https://ruby.sketchup.com/UI/Command.html#proc-instance_method) objects was added in the 2022.0 release.  
Now extensions that need this reference to the proc (like toolbar editors, etc.) no longer need to (nor should) modify the [`UI::Command`](https://ruby.sketchup.com/UI/Command.html) class constructor to “steal” the reference.

> [@john\_mcclenahan](#):
>
> I can get a ‘handle’ on it using (from the Ruby API) UI.menu method
> 
> ```ruby
> myMenu = UI.menu("Window/Component Options")
> 
> ```

No actually that does not work. That just gets a handle on the “Window” menu itself. (Ie, we have asked for path string arguments to get at nested submenu(s), but it has yet to be implemented.)

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [April 11, 2016, 9:13pm UTC](https://forums.sketchup.com/t/how-to-display-window-component-options-from-ruby/23448/3 "2016-04-11T21:13:51Z")

</div>

> [@john\_mcclenahan](#):
>
> Now who would have thought of that, reading the API docs?

Because it is undocumented. Basically it is an OEM Ruby extension.

Knowing how to get there, involves “inside information” from the original author (who is now no longer with the OEM,) and good use of Ruby’s introspection methods.

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [April 11, 2016, 9:26pm UTC](https://forums.sketchup.com/t/how-to-display-window-component-options-from-ruby/23448/4 "2016-04-11T21:26:09Z")

</div>

Dan, double thanks for the clarity of explanation. And for the depth of your own inside knowledge, and your willingness to share it here.
