Skip to content

Instantly share code, notes, and snippets.

View Eneroth3's full-sized avatar

Eneroth3 Eneroth3

  • Lund
View GitHub Profile
module SketchupApplicationHelper
def self.path
Sketchup.find_support_file('sketchup.exe')
end
def self.start
# Need quotation marks around path as it contains spaces.
pid = Process.spawn("\"#{path}\"")
Process.detach(pid)
end
@Eneroth3
Eneroth3 / metric_sketchup.rb
Last active November 13, 2023 13:04
Test if SketchUp uses a metric unit or not
def metric?
unit_options = Sketchup.active_model.options["UnitsOptions"]
return false unless unit_options["LengthFormat"] == Length::Decimal
[Length::Millimeter, Length::Centimeter, Length::Meter].include?(unit_options["LengthUnit"])
end
default = metric? ? 100.mm : 4.inch
puts default
@Eneroth3
Eneroth3 / metric.rb
Last active December 3, 2020 12:57
Test if SketchUp uses metric units
def metric?(model = Sketchup.active_model)
unit_options = model.options["UnitsOptions"]
return false unless unit_options["LengthFormat"] == Length::Decimal
[
Length::Millimeter,
Length::Centimeter,
Length::Meter
].include?(unit_options["LengthUnit"])
end
# Load SketchUp plugins from Git working directories.
#
# Place this script in SketchUp's extension folder and adapt pattern
# to where you keep SketchUp extensions Git repos.
#
# Make sure all Git repos have a folder `src` or `source` containing
# the actual SketchUp extension code, as opposed to tests and other
# project related files.
pattern = "/Users/cenerot/Source/SketchUp Extensions/*/{src,source}/"

When creating interior views you often want to place the cameras as close to the wall as possible to show as much of the room as possible, but without accidentally zoom out through the wall. This plugin places the camera 1 cm away from whatever is straight behind it when the plugin is activated. The distance can also be adjusted from the plugin's menu.

Activated from Extensions > Eneroth Zoom Back.