A ruby code to display dynamic component
-
...options dialog box
do you know about any?
when a dynamic component is introduced in a sketchup model, it is autmatically selected
it would save time to automatically open the options dialog box too... -
you need an App Observer that starts a Model Observer that contains an Components Observer that checks for Dynamic Attributes so you can then use a Sketchup.send_action)__if one exists...
probably easier to set a shortcut key...
john
-
@driven said:
you need an App Observer that starts a Model Observer that contains an Components Observer that checks for Dynamic Attributes so you can then use a Sketchup.send_action)__if one exists...
probably easier to set a shortcut key...
john
thank you for trying
there is no component observer, and there is no sketchupsendaction related to dynamic components...at least i have not find any; i did find an Entityobserver, but it doesn't help...
a shortcut key would be fine if it was possible to embed it in a ruby code line
-
to get a component, you need to use
class MyModelObserver < Sketchup;;ModelObserver def onPlaceComponent(instance) # check it's a DC in here. then trigger the dialog with a win32 call end end
but it needs so many other checks as well...
john
-
@driven said:
you need an App Observer that starts a Model Observer that contains an Components Observer that checks for Dynamic Attributes so you can then use a Sketchup.send_action)__if one exists...
probably easier to set a shortcut key...
john
i found a way, using autoit
https://www.autoitscript.com/site/this code:
SendKeepActive("[CLASS;Sketchup Pro 2017]") ; Simulate entering a string of text. Send("{ALT}") Sleep(500) Send("F") Sleep(500) Send("{ENTER}") Sleep(500) Send("{O}")
can be compiled with Aut2Exe, and then launched from a plugin
-
Taking John's example cross-platform:
class MyModelObserver < Sketchup;;ModelObserver # ! If the DC extension is ever changed, this example could break ! def onPlaceComponent(instance) return nil unless defined?($dc_observers) # check if it's a DC in here; if instance.attribute_dictionaries && instance.attribute_dictionaries['dynamic_attributes'] # then set Selection Tool and trigger the dialog; Sketchup.active_model.select_tool(nil) dc_class = $dc_observers.get_latest_class if dc_class.configure_dialog_is_visible dc_class.get_configure_dialog.bring_to_front else dc_class.show_configure_dialog end dc_class.refresh_configure_dialog end end end
This code is fragile, because it deals with someone's else's extension. They could change it (such as method names,) at any time in the future and this example will break.
-
i have to work to understand what you wrote, observers a re new for me
thank you
@dan rathbun said:
Taking John's example cross-platform:
> class MyModelObserver < Sketchup;;ModelObserver > > # ! If the DC extension is ever changed, this example could break ! > > def onPlaceComponent(instance) > return nil unless defined?($dc_observers) > # check if it's a DC in here; > if instance.attribute_dictionaries && > instance.attribute_dictionaries['dynamic_attributes'] > # then set Selection Tool and trigger the dialog; > Sketchup.active_model.select_tool(nil) > dc_class = $dc_observers.get_latest_class > if dc_class.configure_dialog_is_visible > dc_class.get_configure_dialog.bring_to_front > else > dc_class.show_configure_dialog > end > dc_class.refresh_configure_dialog > end > end > > end >
This code is fragile, because it deals with someone's else's extension. They could change it (such as method names,) at any time in the future and this example will break.
Advertisement