All true, … however there are some public instance methods can can be used with disclaimer.
DISCLAIMER: Use at own risk. The Dynamic Components extension is a Trimble internal extension (that is almost part of the core.) It’s internal functionality and method names could change at any time without warning. This could cause your code “in the wild” to fail, resulting in you needing to patch your code and re-release it.
module AuthorNamespace
module ThisPlugin # defined only if DC extension is pre-loaded !
extend self
DC ||= $dc_observers.get_latest_class
# Test whether the DC Component Attributes dialog is open.
def component_attributes_dialog_open?
DC.manager_dialog_is_visible()
end
# Test whether the DC Component Options dialog is open.
def component_options_dialog_open?
DC.configure_dialog_is_visible()
end
# Closes the DC Component Attributes dialog.
def close_component_attributes_dialog
DC.close_manager_dialog()
end
# Closes the DC Component Options dialog.
def close_component_options_dialog
DC.close_configure_dialog()
end
# Refreshes the DC Component Attributes dialog.
def refresh_component_attributes_dialog
DC.refresh_manager_dialog()
end
# Refreshes the DC Component Options dialog.
def refresh_component_options_dialog
DC.refresh_configure_dialog()
end
# Refreshes both dialogs, clearing the highlight if arg is true.
def refresh_dynamic_component_dialogs(clear_highlight = false)
DC.refresh_dialogs(clear_highlight)
end
# Opens the DC Component Attributes dialog.
def show_component_attributes_dialog
model = Sketchup.active_model
entity = model.selection.empty? ? model : model.selection[0]
DC.show_manager_dialog(entity)
end
# Opens the DC Component Options dialog.
def show_component_options_dialog
DC.show_configure_dialog()
end
# --------------------
# A block form method that closes the DC dialog windows,
# evaluates the given block (passing in any arguments,)
# then restores the dialogs if they were previously open.
def do_with_DC_dialogs_closed(*args)
return nil unless block_given?
atts_was_open = component_attributes_dialog_open?
opts_was_open = component_options_dialog_open?
close_component_attributes_dialog() if atts_was_open
close_component_options_dialog() if opts_was_open
#
result = yield *args # eval the block
#
show_component_attributes_dialog() if atts_was_open
show_component_options_dialog() if opts_was_open
return result
end
end if defined?($dc_observers)
end
Using local method wrappers would allow adapting the DC method calls if they change in future releases, using conditional statements that “duck-type” the DC observer instance using #respond_to?().