Skip to content

Instantly share code, notes, and snippets.

View jimfoltz's full-sized avatar

Jim Foltz jimfoltz

View GitHub Profile
@jimfoltz
jimfoltz / dim-layer.rb
Last active October 9, 2015 08:14
dim-layer.rb
# Switches the active Layer to "DIMS" when DimensionTool is used.
# Puts all Dimensions on DIMS Layer.
module JF
module DimLayer
DIM_LAYER_NAME = "DIMS"
class AppObserver < Sketchup::AppObserver
def expectsStartupNotifications()
@jimfoltz
jimfoltz / trim-and-keep.rb
Created October 10, 2015 11:55
trim-and-keep.rb
# Trim and Keep (C) Copyright 2011 jim.foltz@gmail.com
# Version: 0.1
# gist_id: 39395cc0e6c6ec0010f3
#
# Trim and Keep aims to "fix" SketchUp Pro's Solid Tools Trim function. As it currently
# works, SketchUp's trim changes ComponentInstances into Groups.
#
require 'sketchup'
module JF; class TrimAndKeep
@jimfoltz
jimfoltz / nudge-tool.rb
Last active October 10, 2015 11:56
nudge-tool.rb
module JF
module Nudge
class NudgeTool
def enableVCB?
true
end
@jimfoltz
jimfoltz / detect-dc.rb
Last active October 10, 2015 11:58
detect-dc.rb
module JF
module DetectDC
DICT = "dynamic_attributes"
class AppObserver < Sketchup::AppObserver
def expectsStartupModelNotifications()
return true
end
def onOpenModel(model)
@jimfoltz
jimfoltz / unhide-all.rb
Last active October 10, 2015 13:00
unhide-all.rb
# file: unhide-all.rb
# author: jim.foltz@gmail.com
require 'sketchup.rb'
module JF
module UnhideAll
def self.start
@jimfoltz
jimfoltz / cli.rb
Last active October 10, 2015 13:57
cli.rb
# require 'win32api'
module CLI
module_function
class Cmd
attr_accessor :name, :help, :proc
def initialize(name, help, prc)
@name = name
@help = help
@jimfoltz
jimfoltz / draw-camera-axes.rb
Last active October 10, 2015 14:02
draw-camera-axes.rb
module JF
def self.draw_camera_axes
camera = Sketchup.active_model.active_view.camera
eye = camera.eye
entities = Sketchup.active_model.active_entities
entities.add_cpoint(eye)
@jimfoltz
jimfoltz / component-layers.rb
Last active October 26, 2015 23:16
component-layers.rb
# Right-click an Instance to move it and all sub-components
# to a new set of Layers prefixed by component name.
# Use to keep imported models off your Layers.
#
module JF
module ComponentLayers
def self.separator
"__"
end
@jimfoltz
jimfoltz / limit-scale.rb
Last active October 30, 2015 17:42
limit-scale.rb
# Limit the scale handles for Groups and Instances
UI.add_context_menu_handler do |menu|
model = Sketchup.active_model
selection = model.selection
if selection.nitems == 1 and selection[0].is_a? Sketchup::Group or selection[0].is_a?(Sketchup::ComponentInstance)
menu.add_item("Limit Scale") do
JF::LimitScale.do(selection[0])
end
end
@jimfoltz
jimfoltz / make-dc-door.rb
Last active October 30, 2015 17:43
make-dc-door.rb
# make dc door
# Right-click a Instance, select Make DC Door
UI.add_context_menu_handler do |menu|
if ((sel = Sketchup.active_model.selection).length == 1)
if sel[0].class == Sketchup::ComponentInstance
menu.add_item("Make DC Door") do
ret = UI.inputbox( ["From", "To"], [0, 90], "Degrees")
if ret
entity = sel[0]