Created
October 30, 2017 06:39
-
-
Save hanpama/7a8567045fd4a21f2d980aa159381666 to your computer and use it in GitHub Desktop.
스케치업 도우미
This file contains hidden or 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
def pick_one_surface() | |
model = Sketchup.active_model | |
faces = model.entities.grep(Sketchup::Face) | |
puts(faces.length) | |
return faces[0] | |
end | |
def groupify() | |
face = pick_one_surface() | |
connected_entities = face.all_connected | |
if connected_entities.empty? | |
throw 'END' | |
end | |
group = Sketchup.active_model.entities.add_group(connected_entities) | |
Sketchup.active_model.selection.add(group) | |
end | |
def give_each_group_a_name() | |
Sketchup.active_model.entities.grep(Sketchup::Group).each { |g| | |
bbox = g.bounds | |
points = [] | |
4.times { |x| points.push(bbox.corner(x)) } | |
x = points.reduce(0) { |f, s| f + s.x } / 4 | |
y = points.reduce(0) { |f, s| f + s.y } / 4 | |
g.name = "group_%s_%s" % [ x, y ] | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment