I’m still working on the group for the trim, but does this look better? I also have fixed the folder structure and naming, created the register file as shown, and placed icons in a “Icons” folder. Thanks!
module CaydenWilson
module ProTrim
extend self
#Loading in handles
model = Sketchup.active_model
selection = Sketchup.active_model.selection
entities = Sketchup.active_model.entities
materials = Sketchup.active_model.materials
layer_array = Sketchup.active_model.layers
require 'sketchup.rb'
require 'extensions.rb'
def get_points(axis, height, thickness)
case axis
when X_AXIS
[ [0,0,0], [0,0,height], [thickness,0,0], [thickness,0,height] ]
when Y_AXIS
[ [0,0,0], [0,0,height], [0,thickness,0], [0,thickness,height] ]
end
end
def create_trim_material(materials)
trim_material = Sketchup.active_model.materials.add "Trim"
trim_material.color = [red, green, blue]
trim_group.material = trim_material
end
def build_trim(axis, selection, height, thickness)
#Input to gather data for trim
prompts = ["Trim Height: ", "Trim Thickness:", "Quarter Round:", "R:", "G:", "B:"]
defaults = [5.0,0.5,"No",255.0,255.0,255.0]
list = ["","","Yes|No","","",""]
input = UI.inputbox prompts, defaults, list, "ProTrim"
return unless input
height,thickness,quarter_round,red,green,blue=input
if quarter_round == 'Yes'
quarter_round_width = 0.75
quarter_round_height = 0.75
end
message = "Select edges for your trim path."
result = UI.messagebox(message, MB_OKCANCEL)
if result == IDCANCEL
return
end
pts=get_points(axis, height, thickness)
#Creating a face using array
face = entities.add_face(pts)
edges = face.edges
connected = face.all_connected
face.back_material = "Trim"
material = trim.back_material
face.material = trim
#Selecting edges (path) to extrude on
face.followme( selection.grep(Sketchup::Edge) )
end
def create_trim_layer(layer_array, entities)
new_layer = model.layers.add("Trim")
model.active_layer = new_layer
name = trim
visable = True
end
if !@loaded
submenu = UI.menu("Extensions").add_submenu("ProTrim")
toolbar=UI::Toolbar.new "ProTrim"
cmd = UI::Command.new("Build Trim") { init() }
cmd.small_icon = File.join(__dir__, "Icons", "IconSmall.png")
cmd.large_icon = File.join(__dir__, "Icons", "IconLarge.png")
cmd.menu_text = "ProTrim"
toolbar.add_item cmd
toolbar.show
submenu.add_item(cmd)
# Set the @loaded var to true so this block is only evaluated ONCE:
@loaded = true
end
end
end