Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
decac91
#167 - Replace ProgressDialog with an OS SDK ProgressBar (need to imp…
jmarrec Mar 6, 2026
0f699ff
Initial dialog
macumber Mar 14, 2026
403204f
Style updates
macumber Mar 14, 2026
cdf0ab1
Move files
macumber Mar 14, 2026
5581652
Intermediate checkpoint
macumber Mar 15, 2026
69b2921
Intermediate check point
macumber Mar 15, 2026
04ee576
Ready to start dev testing
macumber Mar 15, 2026
18e01c3
Done for this weekend
macumber Mar 15, 2026
f449735
Merge remote-tracking branch 'origin/167-Remove_Qt' into remove_qt
macumber Mar 16, 2026
5b92aa7
Interim progress
macumber Mar 17, 2026
d1a158d
Good working point
macumber Mar 23, 2026
b5146a0
Remove file with rubocop violations
macumber Mar 23, 2026
26997f7
Address review comments
macumber Mar 23, 2026
f5e6697
Change ProgressDialog to update html dialog
macumber Mar 28, 2026
a67dc2b
Fix remaining issues
macumber Mar 28, 2026
3d125c5
Fix for bug splats on Mac ARM64
macumber Mar 29, 2026
248d12c
Update progress bar in Cleanup_Origins.rb. I guess we have lots of sc…
jmarrec Mar 30, 2026
75f1b12
Replace OpenStudio::Ruleset::ModelUserScript with OpenStudio::Measure…
jmarrec Mar 30, 2026
743eb10
Tweak Assign Building Stories progress bar update
jmarrec Mar 30, 2026
3f84399
Don't center the progress bar if already visible
jmarrec Mar 30, 2026
6949785
Tweak "destroy": hide: only if SU 2026.1, and delay 1s + set done (10…
jmarrec Mar 30, 2026
21e63d1
Return type Correctness: All OpenStudio Measures should always return…
jmarrec Mar 30, 2026
c4f5392
Existing copy pasta bug in one measure
jmarrec Mar 30, 2026
b4a6fd9
Capture failures and set progress bar to red if so
jmarrec Mar 30, 2026
4c25bb4
<title> div is useless, this is set once internally via UI::HtmlDialo…
jmarrec Mar 30, 2026
1b4d914
dlg.visible? returns true after hiding dialog in 2026, always call sh…
macumber Apr 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions plugin/openstudio/lib/DialogManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize

@dialog_interfaces = Set.new

@inspector_dialog = PluginInspectorDialog.new
@inspector_dialog = Inspector::InspectorDialog.new
@inspector_dialog.hide

update_units
Expand All @@ -29,8 +29,8 @@ def save_state

interface_names = @dialog_interfaces.collect { |interface| interface.class.to_s[12..-1] } # Clip the "OpenStudio::" part
Plugin.write_pref('Open Dialogs', interface_names.to_a.join(','))
Plugin.write_pref('Inspector Dialog Visible', @inspector_dialog.isVisible)
@inspector_dialog.saveState
Plugin.write_pref('Inspector Dialog Visible', @inspector_dialog.is_visible)
@inspector_dialog.save_state
end

def restore_state
Expand All @@ -50,16 +50,16 @@ def restore_state

inspector_dialog_visible = Plugin.read_pref('Inspector Dialog Visible')
if inspector_dialog_visible
@inspector_dialog.restoreState
@inspector_dialog.restore_state
@inspector_dialog.show
Comment thread
macumber marked this conversation as resolved.
end
end

def active_interface(interface_class)
#Plugin.log(OpenStudio::Trace, "#{OpenStudio.current_method_name}")

if interface_class == PluginInspectorDialog
return @inspector_dialog.isVisible
if interface_class == Inspector::InspectorDialog
return @inspector_dialog.is_visible
end
return(@dialog_interfaces.find { |interface| interface.is_a? interface_class })
end
Expand Down Expand Up @@ -125,9 +125,9 @@ def update_units
puts "new @units_system = #{@units_system}"

if (@units_system == "IP")
@inspector_dialog.displayIP(true)
@inspector_dialog.set_unit_system("IP")
else
@inspector_dialog.displayIP(false)
@inspector_dialog.set_unit_system("SI")
end

end
Expand Down Expand Up @@ -294,12 +294,12 @@ def selection_changed
watcher_enabled = drawing_interface.disable_watcher if drawing_interface

if idd_object_type
result = @inspector_dialog.setIddObjectType(idd_object_type)
result = @inspector_dialog.set_idd_object_type(idd_object_type)
Plugin.log(OpenStudio::Debug, "selection_changed: setting iddObjectType to #{idd_object_type}, result = #{result.to_s}")
end

if handles
result = @inspector_dialog.setSelectedObjectHandles(handles)
result = @inspector_dialog.set_selected_object_handles(handles)
Plugin.log(OpenStudio::Debug, "selection_changed: setting setSelectedObjectHandles to #{handles.size.to_s}, result = #{result.to_s}")
end

Expand Down
6 changes: 3 additions & 3 deletions plugin/openstudio/lib/MenuManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require("openstudio/lib/GbXMLImporter")
require("openstudio/lib/SddImporter")
require("openstudio/lib/OpenStudioImporter")
require("openstudio/lib/dialogs/PluginInspectorDialog")
require("openstudio/lib/dialogs/InspectorDialog/inspector_dialog")
require("openstudio/lib/dialogs/ColorScaleInterface")
require("openstudio/lib/dialogs/AnimationSettingsInterface")
require("openstudio/lib/dialogs/PreferencesInterface")
Expand Down Expand Up @@ -293,15 +293,15 @@ def create_commands
@loose_geometry_cmd.set_validation_proc { Plugin.dialog_manager.validate(LooseGeometryInterface) if (Plugin.dialog_manager) }

@inspector_dialog_cmd = UI::Command.new("Inspector") {
Plugin.dialog_manager.inspector_dialog.restoreState
Plugin.dialog_manager.inspector_dialog.restore_state
Plugin.dialog_manager.inspector_dialog.show
}
@inspector_dialog_cmd.small_icon = Plugin.dir + "/lib/resources/icons/OSC_inspector" + Plugin.image_ext
@inspector_dialog_cmd.large_icon = Plugin.dir + "/lib/resources/icons/OSC_inspector" + Plugin.image_ext
@inspector_dialog_cmd.tooltip = "Inspector"
@inspector_dialog_cmd.status_bar_text = "Display and edit the selected object"
@inspector_dialog_cmd.set_validation_proc {
Plugin.dialog_manager.validate(PluginInspectorDialog) if (Plugin.dialog_manager)
Plugin.dialog_manager.validate(Inspector::InspectorDialog) if (Plugin.dialog_manager)
}

@surface_search_cmd = UI::Command.new("Surface Search") { Plugin.dialog_manager.show(SurfaceSearchInterface) }
Expand Down
92 changes: 92 additions & 0 deletions plugin/openstudio/lib/ModelEditor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
########################################################################################################################
# OpenStudio(R), Copyright (c) OpenStudio Coalition and other contributors.
# See also https://openstudiocoalition.org/about/software_license/
########################################################################################################################

module OpenStudio

# Maps each SpaceLoadInstance IDD type name (upper-case, colon-style) to:
# :definition_type – IDD type name of the matching Definition object
# :field_index – index of the "Definition Name" field in the instance object
SPACE_LOAD_DEFINITION_MAP = {
'OS:ELECTRICEQUIPMENT' => { definition_type: 'OS_ElectricEquipment_Definition', field_index: 2 },
'OS:GASEQUIPMENT' => { definition_type: 'OS_GasEquipment_Definition', field_index: 2 },
'OS:HOTWATEREQUIPMENT' => { definition_type: 'OS_HotWaterEquipment_Definition', field_index: 2 },
'OS:INTERNALMASS' => { definition_type: 'OS_InternalMass_Definition', field_index: 2 },
'OS:LIGHTS' => { definition_type: 'OS_Lights_Definition', field_index: 2 },
'OS:LUMINAIRE' => { definition_type: 'OS_Luminaire_Definition', field_index: 2 },
'OS:PEOPLE' => { definition_type: 'OS_People_Definition', field_index: 2 },
}.freeze

# Pure-Ruby replacement for OpenStudio::Modeleditor::ensureSpaceLoadDefinition.
#
# Ensures that the given SpaceLoadInstance workspace object has a linked
# Definition object. If the instance already points to a definition, returns
# immediately. Otherwise:
# 1. If the model contains existing definitions of the matching type, asks
# the user whether to reuse one (picks the first) or create a new one.
# 2. Creates a new blank definition and links it to the instance.
#
# @param model_object [OpenStudio::WorkspaceObject] a SpaceLoadInstance
def self.ensureSpaceLoadDefinition(model_object)
return if model_object.nil?

type_key = model_object.iddObject.name.upcase
mapping = SPACE_LOAD_DEFINITION_MAP[type_key]

unless mapping
Plugin.log(OpenStudio::Warn,
"ensureSpaceLoadDefinition: unknown SpaceLoadInstance type '#{type_key}' – skipping")
return
end

definition_type_str = mapping[:definition_type]
field_index = mapping[:field_index]

# If a definition is already linked, nothing to do
current_def = model_object.getTarget(field_index)
return unless current_def.empty?

model = model_object.model
idd_type = OpenStudio::IddObjectType.new(definition_type_str)
existing = model.getObjectsByType(idd_type)

definition_handle = nil

if !existing.empty?
# Ask the user whether to reuse an existing definition or create a new one.
# The C++ code showed a full selector dialog; here we offer a simple YES/NO.
friendly_type = model_object.iddObject.name.sub(/^OS:/, '').gsub(/(?<=[a-z])(?=[A-Z])/, ' ')
answer = UI.messagebox(
"The model has #{existing.size} existing #{friendly_type} Definition(s).\n\n" \
"Click YES to reuse the first existing definition.\n" \
"Click NO to create a new blank definition.",
MB_YESNO
)

if answer == 6 # YES – reuse the first existing definition
definition_handle = existing.first.handle.to_s
end
# NO falls through to create a new definition below
end

if definition_handle.nil?
# Create a new blank definition object
new_def_opt = model.addObject(OpenStudio::IdfObject.new(idd_type))
unless new_def_opt.empty?
definition_handle = new_def_opt.get.handle.to_s
end
end

if definition_handle
model_object.setString(field_index, definition_handle)
else
Plugin.log(OpenStudio::Error,
"ensureSpaceLoadDefinition: failed to create or find a definition for #{type_key}")
end

rescue => e
Plugin.log(OpenStudio::Error, "ensureSpaceLoadDefinition error: #{e.message}")
end

end # module OpenStudio
23 changes: 2 additions & 21 deletions plugin/openstudio/lib/PluginManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ module OpenStudio
require("openstudio")
require("openstudio/lib/AnimationManager")
require("openstudio/lib/CommandManager")
require("openstudio/lib/DialogManager")
require("openstudio/lib/MenuManager")
require("openstudio/lib/ModelEditor")
require("openstudio/lib/ModelManager")
#require("openstudio/lib/SimulationManager")
require("openstudio/lib/ConflictManager")
require("openstudio/lib/DialogManager")
require("openstudio/lib/WorkspaceObject")
require("openstudio/lib/PluginUserScriptRunner")
require("openstudio/sketchup/UI")
Expand All @@ -48,12 +49,6 @@ module OpenStudio

module OpenStudio

if defined?(OpenStudio::Modeleditor::PathWatcher)
ApplicationClass = OpenStudio::Modeleditor::Application
else
ApplicationClass = OpenStudio::Application
end

if OpenStudio::SKETCHUPPLUGIN_CURRENT_METHOD_NAME
# function to return current method name
def self.current_method_name
Expand Down Expand Up @@ -213,10 +208,6 @@ def process_events
end
end

# process events in OpenStudio Model
# this may add events to the Plugin event_queue
OpenStudio::ApplicationClass.instance.processEvents

@model_manager.model_interfaces.each do |model_interface|
model_interface.model_watcher.processAddedObjects
end
Expand Down Expand Up @@ -522,16 +513,6 @@ def log(level, message)
Sketchup.add_observer(AppObserver.new)
end

# initialize QApplication
OpenStudio::ApplicationClass::instance.application(true)
OpenStudio::ApplicationClass::instance.application.setOrganizationName("OpenStudio Coalition")
OpenStudio::ApplicationClass::instance.application.setOrganizationDomain("openstudiocoalition.org")
OpenStudio::ApplicationClass::instance.application.setApplicationName("OpenStudioSketchUpPlugIn")

# get SketchUp Qt Widget if possible
SketchUpWidget = OpenStudio::ApplicationClass::instance.sketchUpWidget
SketchUpWidget.hide if SketchUpWidget

# Create a module constant to reference the plugin object anywhere within the module.
Plugin = PluginManager.new
Plugin.start
Expand Down
11 changes: 7 additions & 4 deletions plugin/openstudio/lib/PluginUserScriptRunner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,11 @@ def run_user_script(name)
model_interface.openstudio_model.setWorkflowJSON(@model_workflow_json)

result = self.result
if not result.stepErrors.empty?
step_result = result.stepResult
if step_result.is_initialized && step_result.get.valueName == "Fail"
has_errors = true
end
if not result.stepErrors.empty?
error_msg += "Errors: \n"
result.stepErrors.each { |error|
error_msg += " " + error + "\n"
Expand All @@ -427,7 +430,7 @@ def run_user_script(name)

# switch render mode back to original
proc = Proc.new {
destroyProgressBar
destroyProgressBar(success: !has_errors && !was_canceled)

model_interface.materials_interface.rendering_mode = starting_rendermode

Expand Down Expand Up @@ -468,9 +471,9 @@ def updateProgress(value)
end

# destroy the progress bar
def destroyProgressBar
def destroyProgressBar(success: true)
if @progress_dialog
@progress_dialog.destroy
@progress_dialog.destroy(success: success)
end
@progress_dialog = nil
end
Expand Down
Loading
Loading