Created
August 17, 2016 01:41
-
-
Save ryanzyy/b334fc67fdb473c30d13fa41db7a02fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sketchup.send_action('showRubyPanel:') | |
$m = Sketchup.active_model | |
$s = Sketchup.active_model.selection | |
$v = Sketchup.active_model.active_view | |
$c = Sketchup.active_model.active_view.camera | |
def dcross(*a) | |
opt = a.last.is_a?(Hash) ? a.pop : {} | |
new_group = $m.entities.add_group | |
new_group.name = 'DEBUG' | |
len = opt[:l] || 100.mm | |
draw_cross = lambda { |p| | |
p1 = p.offset(X_AXIS, len) | |
p2 = p.offset(X_AXIS, -len) | |
p3 = p.offset(Y_AXIS, len) | |
p4 = p.offset(Y_AXIS, -len) | |
new_group.entities.add_line(p1, p2) | |
new_group.entities.add_line(p3, p4) | |
} | |
a.each(&draw_cross) | |
end | |
def dcircle(*a) | |
opt = a.last.is_a?(Hash) ? a.pop : {} | |
new_group = $m.entities.add_group | |
new_group.name = 'DEBUG' | |
r = opt[:l] || 100.mm | |
n = opt[:n] || 8 | |
draw_circle = lambda { |p| | |
arr = [2 * Math::PI / n] * n | |
arr = arr.map.with_index { |v, i| v * i } | |
pts = arr.map { |t| | |
[ | |
p[0] + r*Math.cos(t), | |
p[1] + r*Math.sin(t), | |
p[2] | |
] | |
} | |
new_group.entities.add_line(*(pts + [pts.first])) | |
} | |
a.each(&draw_circle) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment