经过几两天的努力,大体上可以了.算法还是比较合理的
After several or two days of efforts, it is generally OK. The algorithm is still relatively reasonable
# 这段是默认代码,您可以选择使用或删除。。。
mod = Sketchup.active_model # 打开模型
ent = mod.entities # 模型中的所有实体
sel = mod.selection # 当前选择
#- 0 = [0, 0, 0] (left front bottom)
#- 1 = [1, 0, 0] (right front bottom)
#- 2 = [0, 1, 0] (left back bottom)
#- 3 = [1, 1, 0] (right back bottom)
#- 4 = [0, 0, 1] (left front top)
#- 5 = [1, 0, 1] (right front top)
#- 6 = [0, 1, 1] (left back top)
#- 7 = [1, 1, 1] (right back top)
sel.grep(Sketchup::Group) do | grp |
faces = grp.entities.grep(Sketchup::Face)
#top
topl=grp.bounds.corner(4)
topy=grp.bounds.corner(7)
#side
sidl=grp.bounds.corner(5)
sidy=grp.bounds.corner(3)
#front
fonl=grp.bounds.corner(0)
fony=grp.bounds.corner(5)
#get distance
tdis = topl.distance(topy)
sdis = sidl.distance(sidy)
fdis = fonl.distance(fony)
sj=[]
#顶面
if tdis > sdis and tdis > fdis
side_faces = faces.find_all {|f| f.normal == X_AXIS }
end
#侧面
if sdis > tdis and sdis > fdis
side_faces = faces.find_all {|f| f.normal == Z_AXIS }
end
#正面
if fdis > sdis and fdis > tdis
side_faces = faces.find_all {|f| f.normal == Z_AXIS }
end
side_faces.each{|e|
e.material='red'
el=e.edges
el.each {|ed|
sj << (ed.length.to_mm.round(0))
}
}
p sj
# get thinkess
sj.delete_if{|e| e==sj.min }
zwn = sj.count / 2 - 1
puts zwn
end
那么问题来了,想将图形中118mm的面从side_face中删除
不知有哪位可以帮助解决一下.
So the problem comes. I want to remove the 118mm face from the side_faces
I wonder who can help solve it