CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于创建多边形网格 (VBA/ActiveX)

2023-1-4 21:10| 发布者: admin| 查看: 1164| 评论: 0|来自: AutoCAD

摘要: 使用 AddPolyfaceMesh 方法创建多边形网格,每个面可以具有多个顶点。

使用该方法创建多面网格,每个面能够具有多个顶点。AddPolyfaceMesh

创建多面网格类似于创建矩形网格。要创建多面网格,请指定其所有顶点的坐标,然后通过输入该面的所有顶点的顶点号来定义每个面。创建多面网格时,可以将特定边设置为不可见,将其指定给图层,或为其赋予颜色。

要使边不可见,请输入边的顶点数作为负值。

创建多面网格

此示例在模型空间中创建一个对象。更新了活动视口的查看方向,以便更轻松地显示网格的三维性质。PolyfaceMesh

Sub Ch8_CreatePolyfaceMesh()
    'Define the mesh vertices
    Dim vertex(0 To 17) As Double
    vertex(0) = 4: vertex(1) = 7: vertex(2) = 0
    vertex(3) = 5: vertex(4) = 7: vertex(5) = 0
    vertex(6) = 6: vertex(7) = 7: vertex(8) = 0
    vertex(9) = 4: vertex(10) = 6: vertex(11) = 0
    vertex(12) = 5: vertex(13) = 6: vertex(14) = 0
    vertex(15) = 6: vertex(16) = 6: vertex(17) = 1

    ' Define the face list
    Dim FaceList(0 To 7) As Integer
    FaceList(0) = 1
    FaceList(1) = 2
    FaceList(2) = 5
    FaceList(3) = 4
    FaceList(4) = 2
    FaceList(5) = 3
    FaceList(6) = 6
    FaceList(7) = 5
    ' Create the polyface mesh
    Dim polyfaceMeshObj As AcadPolyfaceMesh
    Set polyfaceMeshObj = ThisDrawing.ModelSpace.AddPolyfaceMesh _
 (vertex, FaceList)

    ' Change the viewing direction of the viewport to
    ' better see the polyface mesh
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1
    NewDirection(1) = -1
    NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2025-1-8 19:41

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部