关于mesh取若干简化控制点的方法


大家好,如图是目前的rhino中的一个mesh,我的问题是:
如何取出该mesh的控制点,并简化至千数级个点
目前我想到的方法是将mesh转为nurbs曲面,并用以下的python语言进行取点,

# Creates an array of points on a surface
import rhinoscriptsyntax as rs

def ArrayPointsOnSurface():
    # Get the surface object
    surface_id = rs.GetObject("Select surface", rs.filter.surface)
    if surface_id is None: return

    # Get the number of rows
    rows = rs.GetInteger("Number of rows", 2, 2)
    if rows is None: return

    # Get the number of columns
    columns = rs.GetInteger("Number of columns", 2, 2)
    if columns is None: return

    # Get the domain of the surface
    U = rs.SurfaceDomain(surface_id, 0)
    V = rs.SurfaceDomain(surface_id, 1)
    if U is None or V is None: return

    # Add the points
    for i in xrange(0,rows):
        param0 = U[0] + (((U[1] - U[0]) / (rows-1)) * i)
        for j in xrange(0,columns):
            param1 = V[0] + (((V[1] - V[0]) / (columns-1)) * j)
            point = rs.EvaluateSurface(surface_id, param0, param1)
            rs.AddPoint(point)


# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__ == "__main__":
    # call the function defined above
    ArrayPointsOnSurface()

但是苦于mesh与nurbs之间的转化,并且我也不确定我的想法是否合适?
不知道大家有没有更好的想法? 或者其他的建议?
谢谢!

请试试 ReduceMesh 指令
https://docs.mcneel.com/rhino/8/help/zh-cn/commands/reducemesh.htm

谢谢回复。我用了meshreduce简化部分网格面后。
点坐标导出及编号(升级版).gh (86.5 KB)

现在我遇到的问题是,利用以上代码取点。但是取到的点无法覆盖原mesh,因为起始点似乎无法确定(如图),怎么解决?


ps:代码请见文件下端那部分

ReduceMesh 在 RhinoCommon中有提供API,建议你直接调用
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.reducemeshparameters

rhinocommon和api的意思是? 没太明白。是这个命令的设置参数吗?

请看这里的介绍说明 :backhand_index_pointing_down:
Rhino - What is RhinoCommon?

谢谢。
想问下另一个有关的问题。请详见这段代码,就是取点的坐标,但是我发现点坐标结果与实际rhino中的测量结果有偏差,是grassshopper自带的误差吗,怎么消除这个误差,使结果正确? 是代码哪里有误吗?
test-1113.gh (34.3 KB)

谢谢。

请见上一个信息回复,估计没有@你成功。

你好,请内置你的数据到 *.gh 文件中,如果数据量大,可以筛选一部分做内置,这样别人才能帮你查看问题。


Rhino 中你是怎么测量的,也请说明。

1 个赞

请见截图说明。

1 个赞

请见上述截图说明。内置数据后的gh文件也重新上传了,如果还有问题,请告诉我。谢谢。
test-1113.gh (33.8 KB)

1 个赞

image
还有请问这个电池组的名称是什么?

你的这组 GH 定义是基于某一个点创建工作平面,然后基于这个工作平面获取点的坐标,那么在 Rhino 中按照相同的逻辑复现一次:

  1. 使用指令 CPlane 将默认的工作平面移动到你指定的基准点位置。
  2. 使用指令 EvaluatePt获取要测量点的坐标值。

得到的结果和 GH 定义中得到的结果一致:

Point On Curve/曲线上的点
用法介绍:Grasshopper Online Document

1 个赞