Create Polyface Meshes
From AutoCAD ActiveX
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.
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 listDim FaceList(0 To 7) As IntegerFaceList(0) = 1FaceList(1) = 2FaceList(2) = 5FaceList(3) = 4FaceList(4) = 2FaceList(5) = 3FaceList(6) = 6FaceList(7) = 5' Create the polyface meshDim polyfaceMeshObj As AcadPolyfaceMeshSet polyfaceMeshObj = ThisDrawing.ModelSpace.AddPolyfaceMesh _(vertex, FaceList)' Change the viewing direction of the viewport to' better see the polyface meshDim NewDirection(0 To 2) As DoubleNewDirection(0) = -1NewDirection(1) = -1NewDirection(2) = 1ThisDrawing.ActiveViewport.direction = NewDirectionThisDrawing.ActiveViewport = ThisDrawing.ActiveViewportZoomAllEnd Sub