AddPolyfaceMesh Method (ActiveX)

Creates a polyface mesh from a list of vertices.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddPolyfaceMesh(VerticesList, FaceList)
object

Type: Block, ModelSpace, PaperSpace

The objects this method applies to.

VerticesList

Access: Input-only

Type: Variant (array of doubles)

An array of 3D WCS coordinates used to create the polyface mesh vertices. At least four points (twelve elements) are required for constructing a polyface mesh object. The array size must be a multiple of three.

FaceList

Access: Input-only

Type: Variant (array of integers)

An array of integers representing the vertex numbers for each face. Faces are defined in groups of four vertex index values, so the size of this array must be a multiple of four.

Return Value (RetVal)

Type: PolyfaceMesh

The newly created PolyfaceMesh object.

Remarks

Creating a polyface mesh is similar to creating a rectangular mesh. To create a polyface mesh, you specify the coordinates for its vertices and the vertex numbers for all the vertices of that face.

In the following illustration, face 1 is defined by vertices 1, 5, 6, and 2. Face 2 is defined by vertices 1, 4, 3, and 2. Face 3 is defined by vertices 1, 4, 7, and 5, and face 4 is defined by vertices 3, 4, 7, and 8.



To make an edge invisible, enter the vertex number for the edge as a negative value. For instance, to make the edge between vertices 5 and 7 invisible in the following illustration, you would set the following:

Face 3, vertex 3: -7

Examples

VBA:

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)
)