Component Definition from components window

Another tough problem. I would like to use Components window (ComponentTool) selecting functionality with my tool. What I thought I’ll do is just add ToolObserver and in onActiveToolChanged callback change to my tool.

However I still need selected component definition. Everything is easy when I am selecting new component. I can just took last element of DefinitionsList or connect to onComponentAdded in DefinitionsObserver storing somewhere selected component.

However when second time same component is selected then definition is already in definitions list and onComponentAdded event is not triggered. I checked all events in all observers and all are triggered after placing instance not before. Best solution would be to get selected definition in onActiveToolChanged event but as I see I cannot get any details there.

Is there any solution for my problem or do I need to create my custom component select window?

There’s sadly no way to get the selected component in the component browser in the way you can get the selected material in the material browser. I wish there was though.

Now ya’ know why I used UI.openpanel() for that example in the other thread:

@jelcynek, Well, since you said ANY

There is neat trick that is built-into MS Internet Explorer which is used on PC for the UI::WebDialog frames.
IE has the ability to display a directory / ftp files lists that you can drag and drop SKP files from.

wd = UI::WebDialog::new("Pick Components")
wd.set_url Sketchup.find_support_file("Components/Components Sampler")

The user can scroll and drag from the list, but not navigate out of that folder.
You might be able to use this feature in an Iframe inside a WebDialog, and perhaps give the user some control over what folder is displayed in the Iframe.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.