Hi Everyone ,
I'm trying to write a code to make a real glass size which I want to make all 3 functions of
Glass Offset , Thickness , and Group's name of " Glass Unit " in one time. From what I can do is to make Glass Offset + Thickness. They are all faces , but I want to convert faces to separate groups at the end. How can I add groups and have a name of glass unit ?
def face_offset
model = Sketchup.active_model
model.start_operation( "Face Offset" , true)
selection = model.selection
entities = model.active_entities
arr = []
faces = []
selection.each{|entity|
if entity.class == Sketchup;;Face
arr.push entity
end
}
$face_offset = 13
$glass_thickness = 6
prompts = ["Offset Width [mm] ", "Glass Thickness [mm] "]
defaults = [$face_offset.to_s,$glass_thickness ]
list = ["",""]
input = UI.inputbox prompts, defaults, list, "Offset Face."
doffset = input[0].to_f
$face_offset = doffset
berase = true
# 1. Offset Glass + Erase outer faces
arr_glass = []
arr.each{|entity|
face = face_offset1(entity, doffset.mm, berase)
arr_glass.push face
}
entities.each do |e|
faces.push e if e.is_a? Sketchup;;Face
end
# 2. Glass Thickness
distance = input[1]
faces.each do |e|
e.pushpull distance.mm, true
end
# 3. Make all to be glass groups
# faces.each do |e|(g=entities.add_group(e.all_connected)
# g.name="GLASS UNIT")if e.valid? and e.parent==entities.parent and e.class==Sketchup;;Face
# end
model.commit_operation
end