Resolve [Ruby help] Script for create window sills
-
Hello , Today I wanted Creat script for window sills
my approach is create face manuel
click for selectrun script
( part 1 : select face , creat color , Push -30 mm
Part 2 : select vertical face for push +30)Part 1 work , but Part 2 fail
But Ruby = SyntaxError help me please for resolve the problem
thank you in advance , Benjamin#part 1
model = Sketchup.active_model
ent = model.entities
sel = model.selection
ad = sel.entfaces = []
sel.each do |e|
faces <<e if e.is_a? Sketchup::Face
endfaces.each do |appui|
appuicolor = Sketchup::Color.new(238,130,238)
appui.material = appuicolor
appui.back_material = appuicolorstatus = appui.pushpull(-30.mm , true)
end
#part 2ad.each do |e|
s=Sketchup.active_model.selection;
a=s.to_a;s.clear;
a.grep(Sketchup::Face).each{|f|s.add(f)if f.normal.z==0}faces.each do |facade|
status = facade.pushpull(30.mm )
end
-
Part 1 works if you delete or comment out the ad=sel.ent statement which is invalid.
Part 2 doesn't work because the faces created by the pushpull operation are not automatically added to the selection. Also you reuse the faces array which only contains the original faces selected.
Here is how I would do it
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection SKETCHUP_CONSOLE.clear appuicolor = Sketchup;;Color.new(238,130,238) sel.grep(Sketchup;;Face).each do |appui| appui.material = appuicolor appui.back_material = appuicolor old = ent.to_a status = appui.pushpull(-30.mm , true) new = ent.to_a - old new.grep(Sketchup;;Face).select{|f|f.normal.z==0}.each{|f|f.pushpull 30.mm} end
-
hello , Thank you SDMITCH for help
cordially Benj
Advertisement