请选择 进入手机版 | 继续访问电脑版

01BIM社区

 找回密码
 立即注册

扫一扫,访问微社区

查看: 2073|回复: 2

Entities.intersect_with

[复制链接]

149

主题

485

帖子

1901

积分

金牌会员

Rank: 6Rank: 6

积分
1901
发表于 2021-10-25 05:42:36 | 显示全部楼层 |阅读模式
Entities.intersect_with用法

2021年10月25日


回复

使用道具 举报

149

主题

485

帖子

1901

积分

金牌会员

Rank: 6Rank: 6

积分
1901
 楼主| 发表于 2021-10-25 05:44:42 | 显示全部楼层
本帖最后由 tzbm123456 于 2021-10-25 05:45 编辑

mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
arr=sel.to_a;
en1=arr[0];
en2=arr[1];

gr_entities1=en1.entities;
gr_entities2=en2.entities;

gr_tran1=en1.transformation;
gr_tran2=en2.transformation;
recurse=true;
hidden=true;

gr_entities1.intersect_with recurse, gr_tran1, en2, gr_tran2, hidden, en2

回复 支持 反对

使用道具 举报

149

主题

485

帖子

1901

积分

金牌会员

Rank: 6Rank: 6

积分
1901
 楼主| 发表于 2021-10-25 06:06:13 | 显示全部楼层
本帖最后由 tzbm123456 于 2021-10-25 07:23 编辑

entities = Sketchup.active_model.entities
# (!) You created a circle with so many edges that at the scale
#     you drew it they where pushing the boundary of how small
#     units SketchUp can handle. (1/1000th inch).
#     If you has Edge Outline style enabled you could see that
#     not all edges where fully merged.
#     I reduced the curve segments from 360 to 180.
#     (Do you really need such a high mesh density anyway?)

# make tube
tube = entities.add_group
tube_inner = tube.entities.add_circle Geom:oint3d.new(0,0,0), Geom::Vector3d.new(0,0,1), 5, 180
tube_outer = tube.entities.add_circle Geom:oint3d.new(0,0,0), Geom::Vector3d.new(0,0,1), 6, 180
cross_section_face = tube.entities.add_face tube_outer
inner_face = tube.entities.add_face tube_inner
tube.entities.erase_entities inner_face
cross_section_face.pushpull -10, false

# make a cylinder that punches through the wall
hole_punch = entities.add_group
hole_outer = hole_punch.entities.add_circle Geom:oint3d.new(0,0, 5), Geom::Vector3d.new(0,1,0), 3, 180
face = hole_punch.entities.add_face hole_outer
face.pushpull 10, false

# draw the intersection lines and erase the hole punch
#entities.intersect_with true, hole_punch.transformation, tube, tube.transformation, true, hole_punch
hole_punch.entities.intersect_with true, hole_punch.transformation, tube, tube.transformation, true, tube
hole_punch.erase!

# Find all the edges that belong to the Circle elements drawn
# earlier (including the ones push-pulled).
# (Could also collect these earlier before intersecting by
#  collecting all non-smooth edges.)

#<选择Edge实体,并选择其属于curve的Edge实体>
circles = tube.entities.grep(Sketchup::Edge).select { |e| e.curve }.uniq

# Then we pick out all the faces that isn't connected to these edges and erase them.

#<选择Face实体,并选择其Edges集合于circles相交为空的Face实体>
new_faces = tube.entities.grep(Sketchup::Face).select { |f| (f.edges & circles).empty? }

entities.erase_entities( new_faces )



回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|01BIM社区 - 最专业的BIM技术交流平台 ( 渝ICP备15000873号 )

GMT+8, 2022-5-17 18:48 , Processed in 0.045210 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表