Mxs:收集网格边框边缘

问题描述 投票:0回答:1

我正在尝试收集网格中所有边框(开放边)的边缘,并将这些边存储在一个数组中。更具体地说,我想将边缘分成与网格中有边框一样多的数组。

示例:我们有一个带有2个孔的网格(请参阅附件中的网格图像文件),因此它有2个边框,我希望脚本生成一个包含2个子数组的数组,每个孔有1个子数组/'开放边缘循环'。这个网格的图像:test mesh, vertex numbers indicated in blue/purple, edge numbers indicated in red

如果有人能告诉我将边缘收集到数组中的正确方法是非常感激的。如果您知道/可以想出将边缘分成各自子阵列(对应于网格中的孔/边框)的好方法,请告诉我。

图片:

open edge loops indicated

desired result/output

我尝试过的:

我尝试使用命令选择开放边缘

 polyOp.getOpenEdges $

我确实选择了开放边缘,不幸的是我无法使用此命令“获取”所述开放边缘的边数,因为getOpenEdges命令的结果是一个比特(herehere)。

我已经编写了一些伪代码,它可以在所有打开的边都存储在数组中之后将边分成各自的子数组:

- 注意:open_edges是存储网格的所有开放/边界边缘的数组

i = 0; edge_found = true
while open_edges.count > 0 do(
    current_loop = #()
    while edge_found == true do(
        i += 1
        if i==1 do( append current_loop open_edges[1]; Deleteitem open_edges 1 )

        -- Select 2nd vertex of current_loop[-1]
        -- Find edge in 'open_edges' which has this vertex
        --if(no edge is found)then( edge_found = false )
        --else(  
            -- Append the found edge to 'current_loop'
            -- Remove the found edge from 'open_edges'
            --)
        ) --end while edge_found == true do(
    ) --end while open_edges.count > 0 do(

如果您发现我的代码/方法中的错误将边缘分成各自的子阵列(对应于网格中的孔/边框),或者可以想到更好/更有效的方法来执行此过程,请告诉我。

谢谢!

注意:在附图中:'edge_and_vertex_nums.png'我用红色表示边数,用蓝色/紫色表示顶点数。

mesh 3dsmax maxscript
1个回答
0
投票

试试这个。您还可以简单地将firstHole数组与allOpenEdges进行比较,并删除重复项。

allOpenEdges = (polyop.getOpenEdges $) as array
firstHole = (polyop.getBorderFromEdge $ allOpenEdges[1]) as array

select $
subobjectlevel = 2
polyop.setEdgeSelection $ firstHole
subobjectLevel = 3
max select invert
secondHole = (polyop.getedgeselection $) as array
subobjectLevel = 0

format "count1: %, count2: %\n" firstHole.count secondHole.count
© www.soinside.com 2019 - 2024. All rights reserved.