McNeel Wiki
实现extractPt
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Flamingo

Penguin

Rhino

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

中文(简体)

 
.
Developer.NET
VersionRhino 4

Overview

先选择一个曲面,然后生成网格。再得到网格的边缘。再将该边缘曲线的编辑点添加至文档上。部分代码参考其它页面.

VB.NET

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


        '选择曲面 ,生成网格 再得到网格边 和边的编辑点


        Dim go As New MRhinoGetObject()
        go.SetCommandPrompt("Select surface or polysurface to mesh")
        go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object Or _
                              IRhinoGetObject.GEOMETRY_TYPE_FILTER.polysrf_object)
        go.GetObjects(1, 1)


        Dim rms As IRhinoAppRenderMeshSettings = RhinoApp.AppSettings.RenderMeshSettings()
        Dim mp As New OnMeshParameters(rms.FastMeshParameters())


        Dim onSface As IOnSurface = go.Object(0).Surface()


        If onSface Is Nothing Then
            oRhino.Print("Nothing")
            Exit Sub
        End If


        '生成网格
        Dim oneMesh As OnMesh = onSface.CreateMesh(mp)
        RhinoApp.ActiveDoc.AddMeshObject(oneMesh)
        RhinoApp.ActiveDoc.Redraw()


        Dim mesh1 As IOnMesh = oneMesh


        ' Get the mesh's topology
        Dim mesh_top As IOnMeshTopology = mesh1.Topology()
        Dim lines As New List(Of OnCurve)()


        ' Find all of the mesh edges that have only a single mesh face
        Dim edges As IArrayOnMeshTopologyEdge = mesh_top.m_tope
        Dim ptFrom As New On3dPoint()
        Dim ptTo As New On3dPoint()
        For i As Integer = 0 To edges.Count() - 1
            Dim mesh_edge As IOnMeshTopologyEdge = edges(i)
            If (mesh_edge.m_topf_count = 1) Then
                Dim line As New OnLine()
                Dim p0 As On3fPoint = mesh_top.TopVertexPoint(mesh_edge.m_topvi(0))
                ptFrom.Set(p0.x, p0.y, p0.z)
                Dim p1 As On3fPoint = mesh_top.TopVertexPoint(mesh_edge.m_topvi(1))
                ptTo.Set(p1.x, p1.y, p1.z)
                lines.Add(New OnLineCurve(ptFrom, ptTo)) '这里是小网格线,靠边的.
            End If
        Next 


        '将小网格线合并成整条线
        Dim crv As New MRhinoCurveObject()
        Dim join_tol As Double = 2.1 * RhinoApp.ActiveDoc.AbsoluteTolerance()
        Dim output(0) As OnCurve
        If (RhUtil.RhinoMergeCurves(lines.ToArray(), output, join_tol)) Then
            For i As Integer = 0 To output.Length - 1


                crv.SetCurve(output(i))
                If (RhinoApp.ActiveDoc.AddObject(crv)) Then
                    crv.Select()
                End If


            Next
        End If


        crv.EnableGrips(True) '开启编辑点,只有在开启下才能getGrips
        Dim arint As New Arrayint()
        Dim a() As MRhinoGripObject
        crv.GetGrips(a)
        oRhino.Print("dd:" & a.Length)
        For i As Integer = 0 To a.Length - 1
            RhinoApp.ActiveDoc.AddPointObject(a(i).GripBasePoint) ' GripLocation 
        Next
        crv.EnableGrips(False)
        RhinoApp.ActiveDoc.Redraw()
    end sub
rename · changes · history · subscriptions · lost and found · references · file upload