You are on page 1of 6

 

22

 ) 
( PolygonMesh

" : '(. *

PolygonMesh -
PolygonMesh
MN M
N :

PolygonMesh

.


. PolygonMesh
PolygonMesh :
)RetVal = object.Add3Dmesh(M, N, PointsMatrix

:
: Object ModelSpace PaperSpace . Block
M : N
2 . 255
: PointsMatrix x,y,z
.
Type
. :
acBezierSurfaceMesh - acCubicSurfaceMesh - acQuadSurfaceMesh - SimpleMesh

  22

 ) 
( PolygonMesh

" : '(. *

) SimpleMesh (

.

.
:


SURFU SURFV SURFU M SURFV

N )(6

GetVariable
SetVariable .
Type
SURFU SURFV
MDensity NDensity
M N MDensity
SURFU ) (1 NDensity
SURFV ). (1
MDensity 20 NDensity 30

:

  22

 ) 
( PolygonMesh

" : '(. *

PolygonMesh MVertexCount
NVertexCount

Type SimpleMesh
MDensity . NDensity
PolygonMesh
N
M N

MClose NClose M N

PolygonMesh.NClose = True

PolygonMesh.NClose = False

(' *. : "

( PolygonMesh
   

 )22 

Coordinate
Coordinates
.

:
command Form1 VBcad - 1
Add3Dmesh Caption Add3Dmesh Name

: Form1 Add3Dmesh - 2
Private Sub Add3Dmesh_Click()
'------------------'1) Open AutoCAD
On Error Resume Next
Set Acadapp = GetObject(, "AutoCAD.Application.17")
Acadapp.Documents.Add
Acadapp.Visible = True
Acadapp.WindowState = acMax
If Err.Number <> 0 Then
Set Acadapp = CreateObject("AutoCAD.Application.17")
Acadapp.Documents.Add
Acadapp.Visible = True
Acadapp.WindowState = acMax
Err.Clear
End If
Me.Show
'--------------------'*) Change the viewing direction
Dim NewDirection(0 To 2) As Double
NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
Acadapp.ActiveDocument.ActiveViewport.Direction = NewDirection
Acadapp.ActiveDocument.ActiveViewport = Acadapp.ActiveDocument.ActiveViewport

'--------------------'2) create the PolygonMesh object


Dim MeshObj As AcadPolygonMesh
Dim Msize, Nsize, count As Integer
Dim Points(0 To 47) As Double
' Raw 1
Points(0) = 0: Points(1) = 0: Points(2) = 0
Points(3) = 2: Points(4) = 0: Points(5) = 1
Points(6) = 4: Points(7) = 0: Points(8) = 0
Points(9) = 6: Points(10) = 0: Points(11) = 1
' Raw 2
Points(12) = 0: Points(13) = 2: Points(14) = 0
Points(15) = 2: Points(16) = 2: Points(17) = 1
Points(18) = 4: Points(19) = 2: Points(20) = 0
Points(21) = 6: Points(22) = 2: Points(23) = 1
' Raw 3

(' *. : "

( PolygonMesh
   

 )22 

Points(24) = 0: Points(25) = 4: Points(26) = 0


Points(27) = 2: Points(28) = 4: Points(29) = 1
Points(30) = 4: Points(31) = 4: Points(32) = 0
Points(33) = 6: Points(34) = 4: Points(35) = 0
' Raw 4
Points(36) = 0: Points(37) = 6: Points(38) = 0
Points(39) = 2: Points(40) = 6: Points(41) = 1
Points(42) = 4: Points(43) = 6: Points(44) = 0
Points(45) = 6: Points(46) = 6: Points(47) = 0
' Size
Msize = 4: Nsize = 4
Set MeshObj = Acadapp.ActiveDocument.ModelSpace.Add3Dmesh(Msize, Nsize, Points)

Acadapp.ZoomExtents
MsgBox "you have create a Simple PolygonMesh object"
'--------------------'3) Find the MVertexCount and NVertexCount for mesh
Dim MM, NN As Integer
MM = MeshObj.MVertexCount
NN = MeshObj.NVertexCount
MsgBox "The MVertexCount = " & MM & vbCrLf & _
"The NVertexCount = " & NN
'--------------------'4) Change the Type of PolygonMesh object
MeshObj.Type = acQuadSurfaceMesh
MeshObj.Update
MsgBox "you have Change the Type of PolygonMesh to 'acQuadSurfaceMesh'"
'--------------------'5) Find SURFU and SURFV and MDensity and NDensity
Dim curSURFU As Variant
Dim curSURFV As Variant
Dim curMDensity As Integer
Dim curNDensity As Integer
curSURFU = Acadapp.ActiveDocument.GetVariable("SURFU")
curSURFV = Acadapp.ActiveDocument.GetVariable("SURFV")
curMDensity = MeshObj.MDensity
curNDensity = MeshObj.NDensity
MsgBox "The value of system variable 'SURFU' = " & curSURFU & vbCrLf & _
"The value of system variable 'SURFV' = " & curSURFV & vbCrLf & _
"The value of 'MDensity' property = " & curMDensity & vbCrLf & _
"The value of 'NDensity' property = " & curNDensity
'--------------------'6) change the MDensity and NDensity for the mesh
MeshObj.MDensity = 20
MeshObj.NDensity = 30
MeshObj.Update
MsgBox "The New MDensity for the mesh = 20 " & vbCrLf & _
"The New NDensity for the mesh = 30 "
'--------------------'7) Close the mesh in N direction
MeshObj.NClose = True

  22

 ) 
( PolygonMesh

" : '(. *

MeshObj.Update
"MsgBox "you have Close the mesh in N direction
End Sub

:
-1 : Acadapp
.
-2 : MeshObj PolygonMesh

Points
Msize Nsize
Add3Dmesh ModelSpace
. ActiveDocument
-3 : MVertexCount NVertexCount

.
-4 : Type
acQuadSurfaceMesh
SURFU . SURFV
-5 : SURFU SURFV

GetVariable MDensity
NDensity .
-6 : MDensity NDensity
.
-7 : N
NClose . True

You might also like