Create Polyface Meshes

AutoCAD ActiveX

 
Create Polyface Meshes
 
 
 

Use the AddPolyfaceMesh method to create a polyface mesh, with each face capable of having numerous vertices.

Creating a polyface mesh is similar to creating a rectangular mesh. To create a polyface mesh, specify coordinates for all its vertices and then define each face by entering vertex numbers for all the vertices of that face. As you create the polyface mesh, you can set specific edges to be invisible, assign them to layers, or give them colors.

To make an edge invisible, enter the vertex number for the edge as a negative value. For more information on creating polyface meshes, see the AddPolyfaceMesh method in the ActiveX and VBA Reference.

Create a polyface mesh

This example creates a Polyface Mesh object in model space. The viewing direction of the active viewport is updated to display the three-dimensional nature of the mesh more easily.

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