Offset + Thickness + Groups
-
Hi Everyone ,
I'm trying to write a code to make a real glass size which I want to make all 3 functions ofGlass 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

-
I can do it now !

def glass_groups model = Sketchup.active_model model.start_operation( "Face Offset" , true) selection = model.selection entities = model.active_entities #entities = model.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.to_s ] 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 + Group's Name distance = input[1].to_f n='Glass unit' faces.each do |e| # e.pushpull distance.mm, true g = entities.add_group e e.pushpull(-distance.mm) g.name=n ############### end model.commit_operation end
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement