从顶点列表创建多边形网格。 支持的平台:仅窗口 签名工 务 局: RetVal = object.AddPolyfaceMesh(VerticesList, FaceList) 言论创建多边形网格类似于创建矩形网格。要创建多边面网格,请指定其顶点的坐标以及该面的所有顶点的顶点编号。 在下图中,面 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)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 02:21
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.