Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jimfoltz
Last active October 30, 2015 17:43
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/b295d913abe318038278 to your computer and use it in GitHub Desktop.
Save jimfoltz/b295d913abe318038278 to your computer and use it in GitHub Desktop.
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]
dfn = entity.definition
dfn.set_attribute('dynamic_attributes', 'angle', 0)
dfn.set_attribute('dynamic_attributes', 'onclick', "animate(\"angle\", #{ret[0]}, #{ret[1]})")
dfn.set_attribute('dynamic_attributes', '_rotz_formula', 'angle')
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment