我试图使用SketchUp Ruby从导入的STL中删除垂直元素。
我已经修改了一个片段来给出下面的代码,它选择非水平面。
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.1 and f.normal.z < 0.1}然后我试着调整它来选择非水平边,使用这样的事实,任何这样的边都有一个顶点,与另一个顶点的z位置不同。
s=Sketchup.active_model.selection;
a=s.to_a;
s.clear;
a.grep( Sketchup::Edge ).each {
|edge| s.add(edge) if (edge.end.position.z - edge.other_vertex(edge.end).position.z)}然而,这是选择模型中的所有边缘。有人能指出我哪里出错了吗?
发布于 2014-01-30 11:37:48
最后,我没有尝试编写一行代码,而是编写了以下函数来满足我的需要。
def find_plans()
model = Sketchup.active_model()
s = model.selection()
s.clear()
ents = model.entities
non_horizontal_edges = []
for e in ents
non_horizontal_edges.push( e ) if e.typename() == 'Edge' and (e.end.position.z - e.other_vertex(e.end).position.z).abs > 1
end
ents.erase_entities( non_horizontal_edges )
endhttps://stackoverflow.com/questions/21445942
复制相似问题