CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

AddPolyfaceMesh Method (ActiveX)

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

摘要: 从顶点列表创建多边形网格。

从顶点列表创建多边形网格。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.AddPolyfaceMesh(VerticesList, FaceList)
对象

类型:模型空间,图纸空间

此方法适用的对象。

顶点列表

访问:仅输入

类型:变体(双打数组)

用于创建多边面网格顶点的 3D WCS 坐标数组。构建多边形网格对象至少需要四个点(十二个元素)。数组大小必须是 3 的倍数。

面孔列表

访问:仅输入

类型:变量(整数数组)

表示每个面的顶点编号的整数数组。面以四个顶点索引值为一组定义,因此此数组的大小必须是 4 的倍数。

返回值(RetVal)

类型:多边形网格

新创建的对象。PolyfaceMesh

言论

创建多边形网格类似于创建矩形网格。要创建多边面网格,请指定其顶点的坐标以及该面的所有顶点的顶点编号。

在下图中,面 1 由顶点 1、5、6 和 2 定义。面 2 由顶点 1、4、3 和 2 定义。面 3 由顶点 1、4、7 和 5 定义,面 4 由顶点 3、4、7 和 8 定义。



要使边不可见,请输入边的顶点编号作为负值。例如,要在下图中使顶点 5 和 7 之间的边不可见,您需要设置以下内容:

面 3,顶点 3:-7

例子

工 务 局:

Sub Example_AddPolyfaceMesh()
    
    Dim vertexList(0 To 17) As Double

    'Data
    vertexList(0) = 4: vertexList(1) = 7: vertexList(2) = 0
    vertexList(3) = 5: vertexList(4) = 7: vertexList(5) = 0
    vertexList(6) = 6: vertexList(7) = 7: vertexList(8) = 0
    vertexList(9) = 4: vertexList(10) = 6: vertexList(11) = 0
    vertexList(12) = 5: vertexList(13) = 6: vertexList(14) = 0
    vertexList(15) = 6: vertexList(16) = 6: vertexList(17) = 1
    

    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

    Dim obj As AcadPolyfaceMesh
    Set obj = ModelSpace.AddPolyfaceMesh(vertexList, FaceList)
    obj.Update

    ' 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

Visual LISP:

(vl-load-com)
(defun c:Example_AddPolyfaceMesh()
    ;; This example creates a polyface mesh in model space   
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Define the vertices for the polyface mesh
    (setq vertexList (vlax-make-safearray vlax-vbDouble '(0 . 17)))
    (vlax-safearray-fill vertexList '(4 7 0
                                      5 7 0
                                      6 7 0
                                      4 6 0
                                      5 6 0
                                      6 6 1
                                     )
    )  

    ;; Define the face order for the polyface mesh
    (setq FaceList (vlax-make-safearray vlax-vbInteger '(0 . 7)))
    (vlax-safearray-fill FaceList '(1
                                    2
                                    5
                                    4
                                    2
                                    3
                                    6
                                    5
                                   )
    )

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq obj (vla-AddPolyfaceMesh modelSpace vertexList FaceList))

    ;; Change the viewing direction of the viewport to
    ;; better see the polyface mesh
    (setq NewDirection (vlax-3d-point -1 -1 1))
    (setq activeViewport (vla-get-ActiveViewport doc))
    (vla-put-Direction activeViewport NewDirection)
    (vla-put-ActiveViewport doc activeViewport)
    (vla-ZoomAll acadObj)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 00:58

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部