Skip to content

Instantly share code, notes, and snippets.

@jimfoltz
Last active October 30, 2015 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimfoltz/071aa7b818cbbf5c2228 to your computer and use it in GitHub Desktop.
Save jimfoltz/071aa7b818cbbf5c2228 to your computer and use it in GitHub Desktop.
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
end
module JF
module LimitScale
X = 1
Y = 2
Z = 4
XZ = 8
YZ = 16
XY = 32
XYZ = 64
def self.do(e)
if e.is_a?(Sketchup::Group)
b = e.entities[0].parent.behavior
end
if e.is_a?(Sketchup::ComponentInstance)
b = e.definition.behavior
end
m = b.no_scale_mask?
m = m.to_s(2).split(//)
while m.length < 7
m.unshift(0)
end
m.reverse!
prompts = %w( X Y Z XZ YZ XY XYZ )
r = UI.inputbox(prompts, m, "Scale Mask 1=Disable")
return if r == false
s = r.join
s = "0b" + s.reverse
s = Integer(s)
b.no_scale_mask = s
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment