CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于创建网格 (VBA/ActiveX)

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

摘要: 矩形网格(PolygonMesh 对象)使用平面刻面表示对象的表面。

矩形网格(对象)使用平面刻面表示对象的表面。PolygonMesh

网格密度或分面数根据MN顶点的矩阵定义,类似于由列和行组成的网格。MN分别指定任何给定顶点的列和行位置。您可以在 2D 和 3D 中创建网格,但它们主要用于 3D。

使用该方法创建矩形网格。此方法采用三个值作为输入:M方向上的顶点数、N方向上的顶点数以及包含网格中所有顶点坐标的变体数组。Add3DMesh

创建网格后,使用与属性关闭网格。PolygonMeshMCloseNClose

创建多边形网格

此示例创建一个 4×4 多边形网格。然后调整活动视口的方向,以便更轻松地查看网格的三维性质。

Sub Ch8_Create3DMesh()
    Dim meshObj As AcadPolygonMesh
    Dim mSize, nSize, Count As Integer
    Dim points(0 To 47) As Double

    ' create the matrix of points
    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 2: points(4) = 0: points(5) = 1
    points(6) = 4: points(7) = 0: points(8) = 0
    points(9) = 6: points(10) = 0: points(11) = 1
    points(12) = 0: points(13) = 2: points(14) = 0
    points(15) = 2: points(16) = 2: points(17) = 1
    points(18) = 4: points(19) = 2: points(20) = 0
    points(21) = 6: points(22) = 2: points(23) = 1
    points(24) = 0: points(25) = 4: points(26) = 0
    points(27) = 2: points(28) = 4: points(29) = 1
    points(30) = 4: points(31) = 4: points(32) = 0
    points(33) = 6: points(34) = 4: points(35) = 0
    points(36) = 0: points(37) = 6: points(38) = 0
    points(39) = 2: points(40) = 6: points(41) = 1
    points(42) = 4: points(43) = 6: points(44) = 0
    points(45) = 6: points(46) = 6: points(47) = 0

    mSize = 4: nSize = 4

    ' creates a 3Dmesh in model space
    Set meshObj = ThisDrawing.ModelSpace. _
 Add3DMesh(mSize, nSize, points)

    ' Change the viewing direction of the viewport
    ' to better see the cylinder
    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 )

GMT+8, 2024-5-19 15:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部