Loading... <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">经过大量测试,先将结论公布如下:</p> <!-- /wp:paragraph --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">通过API中的Run.Features或Run.Parts或通过关联关系找到的这两者的集合,都按照空间拓扑逻辑关系排序。</p> <!-- /wp:paragraph --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px"><strong><span class="has-inline-color has-vivid-red-color">Part集合遵循从坐标的正到负,X>Y>Z的排序规则,Feature则恰恰与Part相反。</span></strong></p> <!-- /wp:paragraph --> <!-- wp:spacer {"height":20} --> <div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div> <!-- /wp:spacer --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">看看下面这幅图片,大家猜猜代码中获取到的这几个阀门Part集合的排序该是怎样的。</p> <!-- /wp:paragraph --> <!-- wp:image {"id":1925,"sizeSlug":"large","linkDestination":"media"} --> <figure class="wp-block-image size-large"><a href="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-01.jpg"><img src="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-01-1024x518.jpg" alt="" class="wp-image-1925" style=""></a></figure> <!-- /wp:image --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">公布答案,你猜对了吗,两根Run的结果都是1>2>3。因为他们都有Y向的管子,从Y的正方向走向负方向就决定了这些Part的排序,与Z轴已经无关了。</p> <!-- /wp:paragraph --> <!-- wp:image {"id":1927,"sizeSlug":"large","linkDestination":"media"} --> <figure class="wp-block-image size-large"><a href="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-03.jpg"><img src="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-03.jpg" alt="" class="wp-image-1927" style=""></a></figure> <!-- /wp:image --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">再稍微改动一下,看看他们的排序有变化没,再猜一猜吧。</p> <!-- /wp:paragraph --> <!-- wp:image {"id":1926,"sizeSlug":"large","linkDestination":"media"} --> <figure class="wp-block-image size-large"><a href="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-02.jpg"><img src="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-02-1024x534.jpg" alt="" class="wp-image-1926" style=""></a></figure> <!-- /wp:image --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">公布答案,左边这根排序是3>2>1,右边这根是1>2>3。因为这次两根Run都添加了X轴方向的管子,所以按照X轴的规则,从正方向到负方向,得出此结论。</p> <!-- /wp:paragraph --> <!-- wp:image {"id":1928,"sizeSlug":"large","linkDestination":"media"} --> <figure class="wp-block-image size-large"><a href="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-04.jpg"><img src="https://mrgeng.com/usr/uploads/2021/06/Run-Parts-Order-04.jpg" alt="" class="wp-image-1928" style=""></a></figure> <!-- /wp:image --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">另外注意,不是所有对象集合都有排序,比如Run.Connections获取到的Connection集合,就是乱的。</p> <!-- /wp:paragraph --> <!-- wp:spacer {"height":51} --> <div style="height:51px" aria-hidden="true" class="wp-block-spacer"></div> <!-- /wp:spacer --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px">这些Part和Feature的集合顺序只和空间拓扑逻辑关系有关,<strong><span class="has-inline-color has-vivid-red-color">和流向无关</span></strong>。延伸一下,如果一个Part有两个端口,并且在元件库里规定了进出口,这时如果Run设置了流向,那么和Run的FlowDirection值相同的端口就肯定是在上游;还有一点,我们画管子的时候有起点终点,也就是StartLocation和EndLocation,当Run的FlowDirection为2(In),也就是DOWNSTREAM的时候,这根Run的起点正好是StartLocation,当Run的FlowDirection为1(Out),也就是UPSTREAM的时候,这根Run的起点正好是EndLocation。这给我们按照流向去重新排序Part或Feature提供了一些思路,其实按照流向排序出来的Part集合才是设计中经常需要用到的。</p> <!-- /wp:paragraph --> <!-- wp:paragraph {"style":{"typography":{"fontSize":"16px"}}} --> <p style="font-size:16px"><strong><span class="has-inline-color has-vivid-red-color">2021年7月22日更正:</span></strong>PipeRun的两个端口根据用户建模的顺序,会有所不同,用户实际建模的情况很复杂,不一定是从Run的一端建向另一端,有可能是从中间某个管件开始,向两边建模,也有可能是后期合并起来的两个Run,所以这个端口是StartLocation还是EndLocation是很随机的,无法通过它和FlowDirection的关系来排序管件。</p> <!-- /wp:paragraph --> 最后修改:2025 年 03 月 13 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏