rs.surface格式转换为Rhino.Geo.brep格式

我使用 rs.AddLoftSrf()生成了Surface,其type是System.Guid形式。可是接下来我需要的是一个Type为Rhino.Geometry.Brep格式的surface或Brep,进行后续的网格剖分。
使用rs.Addloftsrf()生成的surface,是一个Guid,如下图所示:


请问如何转化成Rhino.Geometry.Brep的格式:

试试

import scriptcontext as sc
sc.doc.Objects.Find

或者

import Rhino.RhinoDoc as rr

rr.ActiveDoc.Objects.FindId()
1 个赞

谢谢,按照上面代码sc.doc.Objects.Find的确可以将Guid直接得到一个type为Rhino.DocObject.BrepObject文件,但并不直接是Rhino.Geometry.Brep,如图所示的brep:

我接着尝试了通过brep = Rhino.Geometry.Brep()方式将DocObject.BrepObject格式转为了Rhino.Geometry.Brep的type。

……
#    Surfce = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(Surface[0])
    brep = scriptcontext.doc.Objects.Find(Surface[0])
    brep = Rhino.Geometry.Brep()
    # 调函生成网格
    if brep.IsValid:
        class2 = wanggehua(brep, dict_para)
        class2.BrepToMesh11()

得到的结果将brep的type转变成Rhino.Geometry.Brep,但是brep.IsValid = False?


而我需要真正有效的Brep进行后续的网格剖分 mesh.CreateFromBrep()。

所以我想得到brep.IsValid = True的有效的brep,有什么方法吗?

你这个方法(brep = Rhino.Geometry.Brep())肯定是不行的,你这个是新建了一个brep实例,把以前的brep覆盖了,是没有值的brep。

#coding=utf-8
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.RhinoDoc as rr

guid  = rs.GetObject("选中多重曲面",rs.filter.polysurface)
if(guid):
    brep = sc.doc.Objects.Find(guid).Geometry
    print type(brep)
    
    brep2 = rr.ActiveDoc.Objects.FindId(guid).Geometry
    print type(brep2)
2 个赞

感谢感谢!解决了 :+1: