xlin
September 19, 2021, 2:30am
9
xlin:
# 这段是默认代码,您可以选择使用或删除。。。
mod = Sketchup.active_model # 打开模型
ent = mod.entities # 模型中的所有实体
sel = mod.selection # 当前选择
def min(*args)
args.min
end
def max(*args)
args.max
end
#p=mod.path.gsub(/.skp$/,'_TMY.csv')
#f=File.open(p,'w')
sel.grep(Sketchup::Group) do | grp |
s=[]
pt=grp.bounds.max
pt1=grp.bounds.min
s << grp.bounds.width
s << grp.bounds.height
s << grp.bounds.depth
temp0=s.max
#最大数 temp0
temp2=s.min
#最小数
s.delete_if{|e| e==s.min }
temp1=s.min
#temp1 中间数
grp.entities.grep(Sketchup::Edge) do |e1|
next unless e1.length == temp2 #当边长等于排宽时
#result = e1.faces[0].classify_point(pt1)
#if result == Sketchup::Face::PointNotOnPlane
if e1.faces[0].area > e1.faces[1].area
bc1=e1.faces[0].area / e1.length
p bc1.to_mm
else
bc2=e1.faces[1].area / e1.length
p bc2.to_mm
end
#end #end result
end #end temp2
end
更新了一下取值,以免temp0 与 temp1 一样大时无法取得.采用数组方式获取就不存在这样的问题
The value is updated to avoid that it cannot be obtained when temp0 is as large as temp1. There is no such problem when it is obtained by array