-
Do not double post. It is a violation of the forum guidelines.
Please fix the first, and delete the second. -
As I already said above, please post code properly in these forums.
Read: [How to] Post correctly formatted and colorized code on the forum? -
All of your code needs to be within a toplevel author namespace module.
Then each one of your extensions should be in it’s own submodule inside your namespace module. -
These statements …
require 'sketchup.rb' require 'extenions.rb'
… are not needed as SketchUp loads them automatically before loading extensions.
(This has been done since SketchUp version 2014 and it’s use of Ruby 2.x.) -
Use an extension registrar filename that is unique. The “Plugins” folder file space is a shared space. Your extension registrar script (in the “Plugins” folder,) should be named like:
"CaydenWilson_TrimProfiler.rb"
, and the extension subfolder needs to have the same name (without the “.rb
” extension,) ie: folder"CaydenWilson_TrimProfiler"
See:
class
SketchupExtension
The filenames within your extension subfolder(s) can be whatever you wish. Ie:
"TrimProfiler_main.rb"
or"main.rb"
, etc. One of these files will be the loader file that loads all the rest of the extensions files (if there are any.) -
Do not open a model messagebox during SketchUp startup. It will block the startup cycle and the user will have to dismiss the messagebox manually. (A good way to anger users.)
Instead, use aUI::Notification
balloon (that can slide into view down in the lower right corner) if you really must inform the user of an important fact during startup. -
You cannot use
gets
in SketchUp’s embedded Ruby, because standard IO is not like in a normal Ruby shell (IRB.) SketchUp’s Ruby Console has hijacked it.
Instead, you must useUI.inputbox
method to display entry boxes or dropdown select controls for the user. -
As you work on an extension, you’ll be reloading it manually as your make changes to methods.
This means you must protect the UI building (commands, menus, toolbars) so they only get created once when your module loads the first time.
This will be your pattern …
# encoding: UTF-8
module CaydenWilson
module ProTrim
extend self
# CONSTANTS go here ...
# Module variables go here ...
def draw_trim_profile
# Method code goes here ...
end
# More methods go here ...
if !@loaded
# Create commands, submenus, menu items
# and toolbar objects here:
UI.menu('Extensions').add_item('CW Designs: ProTrim') {
draw_trim_profile()
}
@loaded = true
end
end
end