如何使用Ruby API在SketchUp中制作空心圆柱体

时间:2014-07-08 17:05:49

标签: ruby sketchup

我需要完成的基本上是一个墙壁厚度为零的圆柱体。现在,如果你需要更好地理解我的意思,想象一下手动绘制一个圆圈,然后使用 pushpull 工具使其成为一个圆柱体,然后删除顶面和底面。起初,我使用了这篇文章中建议的方法:

Punching a hole through a cylinder using Sketchup Ruby API

其中外半径和内半径相差大约1e-02米,但现在我意识到它实际上必须是一个无穷小的厚度,无论你放大多远,所以你看到的只是一条线。

我尝试使用以下基本代码段完成此操作:

entities = Sketchup.active_model.active_entities

circle = entities.add_circle(Geom::Point3d.new(0,0,0), Geom::Vector3d.new(0,0,1), 20)
face = entities.add_face(circle)
face.pushpull(-10, true)

# now from here, it can be either pushpulled downwards by the same amount (10 in this case
# leaving only a bottom face)
# or the entity 'face' can be erased (leaving only a top face) as in the following

entities.erase_entities(face)

所以我的问题是,如何删除两个面以便只留下圆柱?

谢谢。

1 个答案:

答案 0 :(得分:0)

我找到了答案,解决方案就是两者兼而有之。也就是说, pushpull 向内转移相同数量,然后使用以下内容删除面部: entities.erase_entities(face)。

entities = Sketchup.active_model.active_entities

circle = entities.add_circle(Geom::Point3d.new(0,0,0), Geom::Vector3d.new(0,0,1), 20)
face = entities.add_face(circle)

face.pushpull(-10, true)
face.pushpull(10, true)

entities.erase_entities(face)