Skip to content

Commit

Permalink
Merge pull request #52 from openstudiocoalition/develop
Browse files Browse the repository at this point in the history
Merge for 1.0.1 release
  • Loading branch information
macumber committed Aug 6, 2020
2 parents 115b764 + 63c13cb commit 789f97c
Show file tree
Hide file tree
Showing 14 changed files with 1,123 additions and 961 deletions.
2 changes: 1 addition & 1 deletion plugin/openstudio.rb
Expand Up @@ -31,7 +31,7 @@
require 'rbconfig'

$OPENSTUDIO_SKETCHUPPLUGIN_NAME = "OpenStudio"
$OPENSTUDIO_SKETCHUPPLUGIN_VERSION = "3.0.0"
$OPENSTUDIO_SKETCHUPPLUGIN_VERSION = "1.0.1"
$OPENSTUDIO_SKETCHUPPLUGIN_LAUNCH_GETTING_STARTED_ON_START = false

ext = SketchupExtension.new($OPENSTUDIO_SKETCHUPPLUGIN_NAME, "OpenStudio/Startup.rb")
Expand Down
18 changes: 12 additions & 6 deletions plugin/openstudio/lib/MenuManager.rb
Expand Up @@ -580,17 +580,17 @@ def create_commands
@openstudio_cmd.status_bar_text = "Launch Openstudio"
@openstudio_cmd.set_validation_proc { enable_if_model_interface }

@online_help_cmd = UI::Command.new("Online Help") { UI.openURL("http://nrel.github.io/OpenStudio-user-documentation/reference/sketchup_plugin_interface/") }
@online_help_cmd = UI::Command.new("Online Reference") { UI.openURL("https://openstudiocoalition.org/reference/sketchup_plugin_interface/") }
@online_help_cmd.small_icon = Plugin.dir + "/lib/resources/icons/Help-16.png"
@online_help_cmd.large_icon = Plugin.dir + "/lib/resources/icons/Help-24.png"
@online_help_cmd.tooltip = "Online OpenStudio Help"
@online_help_cmd.status_bar_text = "View the Online OpenStudio Help"
@online_help_cmd.set_validation_proc { MF_ENABLED }

@forum_cmd = UI::Command.new("Forum") { UI.openURL("https://www.openstudio.net/forum") }
@forum_cmd = UI::Command.new("Unmet Hours Forum") { UI.openURL("https://unmethours.com/questions/scope:all/sort:activity-desc/tags:sketchup/page:1/") }
@forum_cmd.set_validation_proc { MF_ENABLED }

@contact_cmd = UI::Command.new("Contact Us") { UI.openURL("https://www.openstudio.net/contact") }
@contact_cmd = UI::Command.new("Contact Us") { UI.openURL("mailto:osc@openstudiocoalition.org") }
@contact_cmd.set_validation_proc { MF_ENABLED }

# Shortcuts for SketchUp Commands
Expand Down Expand Up @@ -712,9 +712,9 @@ def create_commands
@prefs_cmd = UI::Command.new("Preferences") { Plugin.dialog_manager.show(PreferencesInterface) }
@prefs_cmd.set_validation_proc { MF_ENABLED }

@update_cmd = UI::Command.new("Check For Update") { Plugin.update_manager = PluginUpdateManager.new("SketchUp Plug-in", true) }
@update_cmd = UI::Command.new("Check For Update") { Plugin.update_manager = PluginUpdateManager.new(true) }
@update_cmd.set_validation_proc {
if Plugin.update_manager.nil?
if $OPENSTUDIO_UPDATE_MANAGER && Plugin.update_manager.nil?
MF_ENABLED
else
MF_GRAYED
Expand Down Expand Up @@ -788,7 +788,13 @@ def create_menus
@help_menu.set_validation_proc(id) { MF_ENABLED }

id = @plugin_menu.add_item(@update_cmd)
@plugin_menu.set_validation_proc(id) { MF_ENABLED }
@plugin_menu.set_validation_proc(id) {
if $OPENSTUDIO_UPDATE_MANAGER && Plugin.update_manager.nil?
MF_ENABLED
else
MF_GRAYED
end
}

@plugin_menu.add_separator
@plugin_menu.add_item(@openstudio_cmd)
Expand Down
10 changes: 7 additions & 3 deletions plugin/openstudio/lib/ModelManager.rb
Expand Up @@ -101,16 +101,20 @@ def new_from_skp_model(skp_model)

openstudio_path = skp_model.openstudio_path
openstudio_entities = skp_model.openstudio_entities

if (openstudio_path && !openstudio_path.empty?) || (openstudio_entities.size > 0)
openstudio_materials = skp_model.openstudio_materials

if (openstudio_path && !openstudio_path.empty?) || (openstudio_entities.size > 0) || (openstudio_materials.size > 0)

message = "Removing previously linked OpenStudio content."
message += "\n\nOpen OpenStudio model at '#{openstudio_path}' to restore content."
if (openstudio_path && !openstudio_path.empty?)
message += "\n\nOpen OpenStudio model at '#{openstudio_path}' to restore content."
end
UI.messagebox(message, MB_OK)

# remove all OpenStudio content so user is not confused
skp_model.start_operation("Remove all OpenStudio Content", true)
skp_model.delete_openstudio_entities
openstudio_materials.each {|m| skp_model.materials.remove(m)}
skp_model.commit_operation
end

Expand Down
19 changes: 9 additions & 10 deletions plugin/openstudio/lib/PluginManager.rb
Expand Up @@ -35,7 +35,12 @@
require("openstudio/lib/ModelManager")
#require("openstudio/lib/SimulationManager")
require("openstudio/lib/ConflictManager")
require("openstudio/lib/UpdateManager")
begin
require("openstudio/lib/UpdateManager")
$OPENSTUDIO_UPDATE_MANAGER = true
rescue LoadError, NameError
$OPENSTUDIO_UPDATE_MANAGER = false
end
require("openstudio/lib/WorkspaceObject")
require("openstudio/lib/PluginUserScriptRunner")

Expand All @@ -46,6 +51,7 @@
require("fileutils")

$OPENSTUDIO_APPLICATION_DIR
$OPENSTUDIO_VERSION = OpenStudio::openStudioVersion
$OPENSTUDIO_SKETCHUPPLUGIN_DIR = File.dirname(__FILE__)

$OPENSTUDIO_SKETCHUPPLUGIN_DEVELOPER_MENU = false # default is false, enable to see developer menu
Expand Down Expand Up @@ -172,8 +178,8 @@ def start
@user_script_runner.discover_user_scripts

@update_manager = nil
if Plugin.read_pref("Check For Update #{self.version}")
@update_manager = PluginUpdateManager.new("SketchUp Plug-in", false)
if $OPENSTUDIO_UPDATE_MANAGER && Plugin.read_pref("Check For Update #{self.version}")
@update_manager = PluginUpdateManager.new(false)
end

@conflict_manager = ConflictManager.new
Expand Down Expand Up @@ -410,12 +416,6 @@ def default_preferences
hash['Open Dialogs'] = ""
hash['Inspector Dialog Visible'] = ""

if (platform == Platform_Windows)
hash['Text Editor Path'] = "C:/WINDOWS/system32/notepad.exe"
elsif (platform == Platform_Mac)
hash['Text Editor Path'] = "/Applications/TextEdit.app"
end

return(hash)
end

Expand All @@ -434,7 +434,6 @@ def clear_preferences
write_pref("Last Schedules Import Dir", nil)
write_pref("Last Space Loads Import Dir", nil)
write_pref("Open Dialogs", nil)
write_pref("Text Editor Path", nil)
write_pref("Warn on Idf Export", nil)
write_pref("Warn on gbXML Export", nil)
write_pref("Show Errors on Idf Translation", nil)
Expand Down
30 changes: 17 additions & 13 deletions plugin/openstudio/lib/UpdateManager.rb
Expand Up @@ -29,34 +29,38 @@

module OpenStudio

class PluginUpdateManager < UpdateManager
class PluginUpdateManager < OpenStudio::Modeleditor::GithubReleases

def initialize(appName, verbose)
super(appName)
def initialize(verbose)
super("openstudiocoalition", "openstudio-sketchup-plugin")
@verbose = verbose
Sketchup.status_text = "OpenStudio checking for update"

proc = Proc.new {
self.waitForFinished
self.onFinished
}

Plugin.add_event( proc )
end

def replyProcessed()

def onFinished
if not self.error
if (self.newMajorRelease or self.newMinorRelease)
mostRecentVersion = self.mostRecentVersion
mostRecentDownloadUrl = self.mostRecentDownloadUrl
button = UI.messagebox("A newer version #{mostRecentVersion} of OpenStudio is ready for download.\n" +
if (self.newReleaseAvailable)
button = UI.messagebox("A newer version of the OpenStudio SketchUp Plug-in is ready for download.\n" +
"Do you want to update to the newer version?\n\n" +
"Click YES to visit the OpenStudio website to get the download.\n" +
"Click YES to visit the OpenStudio SketchUp Plug-in website.\n" +
"Click NO to skip this version and not ask you again.\n" +
"Click CANCEL to remind you again next time.", MB_YESNOCANCEL)
if (button == 6) # YES
UI.openURL(mostRecentDownloadUrl)
UI.openURL(self.releasesUrl)
elsif (button == 7) # NO
Plugin.write_pref("Check For Update #{Plugin.version}", false)
end
elsif (@verbose)
UI.messagebox("You currently have the most recent version of OpenStudio.")
UI.messagebox("You currently have the most recent version of the OpenStudio SketchUp Plug-in.")
else
puts "You currently have the most recent version of OpenStudio."
puts "You currently have the most recent version of the OpenStudio SketchUp Plug-in."
end
elsif (@verbose)
UI.messagebox("Error occurred while checking for update.")
Expand Down
1 change: 1 addition & 0 deletions plugin/openstudio/lib/dialogs/AboutInterface.rb
Expand Up @@ -42,6 +42,7 @@ def initialize

def populate_hash
@hash['OPENSTUDIO_SKETCHUPPLUGIN_VERSION'] = "#{$OPENSTUDIO_SKETCHUPPLUGIN_VERSION}"
@hash['OPENSTUDIO_VERSION'] = "#{$OPENSTUDIO_VERSION}"
end

end
Expand Down
43 changes: 7 additions & 36 deletions plugin/openstudio/lib/dialogs/PreferencesDialog.rb
Expand Up @@ -48,52 +48,23 @@ def initialize(container, interface, hash)

def add_callbacks
super
@container.web_dialog.add_action_callback("on_browse_text_editor") { browse_text_editor }
@container.web_dialog.add_action_callback("on_browse_exe") { browse_exe }
@container.web_dialog.add_action_callback("on_browse_openstudio_dir") { browse_openstudio_dir }
end

def browse_openstudio_dir
openstudio_dir = @hash['OPENSTUDIO_DIR']

def browse_text_editor
path = @hash['TEXT_EDITOR_PATH']

if (path.nil? or path.empty?)
path = Plugin.default_preferences['Text Editor Path']
end

dir = File.dirname(path)
file_name = File.basename(path)

if (not File.exist?(dir))
dir = ""
end

if (path = UI.open_panel("Locate Text Editor Program", dir, file_name))
path = path.split("\\").join("/") # Have to convert the file separator for other stuff to work later
# Above is a kludge...should allow any separators to be cut and paste into the text box
@hash['TEXT_EDITOR_PATH'] = path
update
end
end

def browse_exe
path = @hash['ENERGYPLUS_PATH']

if (path.nil? or path.empty?)
path = Plugin.default_preferences['EnergyPlus Path']
end

dir = File.dirname(path)
file_name = File.basename(path)
dir = File.dirname(openstudio_dir)
file_name = File.basename(openstudio_dir)

if (not File.exist?(dir))
dir = ""
end

if (path = UI.open_panel("Locate EnergyPlus Program", dir, file_name))
if (path = UI.open_panel("Locate OpenStudio Dir", dir, file_name))
path = path.split("\\").join("/") # Have to convert the file separator for other stuff to work later
# Above is a kludge...should allow any separators to be cut and paste into the text box

@hash['ENERGYPLUS_PATH'] = path
@hash['OPENSTUDIO_DIR'] = path
update
end
end
Expand Down
61 changes: 18 additions & 43 deletions plugin/openstudio/lib/dialogs/PreferencesInterface.rb
Expand Up @@ -46,55 +46,32 @@ def populate_hash
@hash['NEW_ZONE_FOR_SPACE'] = Plugin.read_pref("New Zone for Space")
@hash['DISABLE_USER_SCRIPTS'] = Plugin.read_pref("Disable OpenStudio User Scripts")
@hash['UNIT_SYSTEM'] = Plugin.read_pref("Unit System")
@hash['TEXT_EDITOR_PATH'] = Plugin.read_pref("Text Editor Path")
@hash['OPENSTUDIO_DIR'] = Plugin.read_pref("OpenStudioDir")

@hash['SHOW_ERRORS_ON_IDF_TRANSLATION'] = Plugin.read_pref("Show Errors on Idf Translation")
@hash['SHOW_WARNINGS_ON_IDF_TRANSLATION'] = Plugin.read_pref("Show Warnings on Idf Translation")
@hash['ENERGYPLUS_PATH'] = Plugin.read_pref("EnergyPlus Path")
end


def report

path = @hash['TEXT_EDITOR_PATH']
# Should filter out any arguments that get passed for line number, etc.
# For example: textpad.exe -l%1 -p
if (path.nil? or path.empty?)
# do nothing
elsif (not File.exists?(path))
UI.messagebox("WARNING: Bad file path for the text editor.")
openstudio_dir = @hash['OPENSTUDIO_DIR']

key_file = nil
sketchup_version = Sketchup.version.split('.').first.to_i
if sketchup_version >= 19
key_file = File.join(openstudio_dir, "Ruby/openstudio_modeleditor.rb")
else
key_file = File.join(openstudio_dir, "Ruby/openstudio.rb")
end

if (openstudio_dir.nil? or openstudio_dir.empty?)
# do nothing, assume user wants to clear
elsif (not File.exists?(openstudio_dir))
UI.messagebox("WARNING: #{openstudio_dir} does not exist.")
elsif (not File.exists?(key_file))
UI.messagebox("WARNING: #{key_file} does not exist.")
end

# DLM: this is no longer needed as simulations are not run from the plugin
#path = @hash['ENERGYPLUS_PATH']
#if (path.nil? or path.empty?)
# # do nothing
#elsif (not File.exists?(path))
# UI.messagebox("WARNING: Bad file path for the EnergyPlus engine.")
#else
# idd_path = File.dirname(path) + "/Energy+.idd"
# if (not File.exists?(idd_path))
# UI.messagebox("WARNING: Cannot locate the input data dictionary (IDD) in the EnergyPlus directory.")
# #@hash['ENERGYPLUS_PATH'] = Plugin.read_pref("EnergyPlus Path")
# #@dialog.update
# #return(false)
# else
#
# # check idd version
# user_version = "Unknown"
# File.open(idd_path, 'r') do |file|
# line = file.gets
# if md = /IDD_Version (\d+\.\d+\.\d+)/.match(line)
# user_version = md[1]
# end
# end
#
# if (user_version != Plugin.energyplus_version)
# UI.messagebox("WARNING: The EnergyPlus engine you have specified is version " + user_version + ". The plugin is designed for version " +
# Plugin.energyplus_version + ".\nThere might be problems with compatibility. Try updating your EnergyPlus engine if there are a lot of simulation errors.")
# end
# end
#end

need_update = false
if @hash['SHOW_WARNINGS_ON_IDF_EXPORT'] and not @hash['SHOW_ERRORS_ON_IDF_EXPORT']
Expand All @@ -106,12 +83,10 @@ def report
Plugin.write_pref("New Zone for Space", @hash['NEW_ZONE_FOR_SPACE'])
Plugin.write_pref("Disable OpenStudio User Scripts", @hash['DISABLE_USER_SCRIPTS'])
Plugin.write_pref("Unit System", @hash['UNIT_SYSTEM'])
Plugin.write_pref("Text Editor Path", @hash['TEXT_EDITOR_PATH'])
Plugin.write_pref("OpenStudioDir", @hash['OPENSTUDIO_DIR'])

Plugin.write_pref("Show Errors on Idf Translation", @hash['SHOW_ERRORS_ON_IDF_TRANSLATION'])
Plugin.write_pref("Show Warnings on Idf Translation", @hash['SHOW_WARNINGS_ON_IDF_TRANSLATION'])
Plugin.write_pref("EnergyPlus Path", @hash['ENERGYPLUS_PATH'])

if (@hash['UNIT_SYSTEM'] != Plugin.dialog_manager.units_system)
Plugin.dialog_manager.update_units
end
Expand Down
11 changes: 7 additions & 4 deletions plugin/openstudio/lib/dialogs/html/About.html
Expand Up @@ -18,18 +18,21 @@

<center>

<a href="https://www.openstudio.net/" target="_blank"><img src="sp_png_256x256.png" border="0"></a>
<a href="https://openstudiocoalition.org/" target="_blank"><img src="sp_png_256x256.png" border="0"></a>

<br>

<span style="font-size:x-large;">OpenStudio SketchUp Plug-in</span><br><br>
<input id="OPENSTUDIO_SKETCHUPPLUGIN_VERSION" name="OPENSTUDIO_SKETCHUPPLUGIN_VERSION" type="text" size="50" class="static_text" style="text-align:center; border:0; border-style:solid;" readonly><br>
<a href="https://www.openstudio.net/" target="_blank">https://www.openstudio.net</a><br><br>
SketchUp Plug-in Version:<br><input id="OPENSTUDIO_SKETCHUPPLUGIN_VERSION" name="OPENSTUDIO_SKETCHUPPLUGIN_VERSION" type="text" size="50" class="static_text" style="text-align:center; border:0; border-style:solid;" readonly><br>
<a href="https://openstudiocoalition.org/" target="_blank">https://openstudiocoalition.org/</a><br><br>

OpenStudio Version:<br><input id="OPENSTUDIO_VERSION" name="OPENSTUDIO_VERSION" type="text" size="50" class="static_text" style="text-align:center; border:0; border-style:solid;" readonly><br>
<a href="https://openstudio.net" target="_blank">https://openstudio.net/</a><br><br>

Developed by the National Renewable Energy Laboratory<br>
For the United States Department of Energy<br><br>

Copyright &copy; 2008-2020, Alliance for Sustainable Energy<br><br>
Copyright &copy; 2008-2020, Alliance for Sustainable Energy, LLC, and other contributors<br><br>

<input id="ok" onclick="onOK()" type="button" class="button" value=" OK ">

Expand Down

0 comments on commit 789f97c

Please sign in to comment.