You are on page 1of 3

3Dpolyline

3Dpolyline :
)RetVal = object.Add3Dpoly(PointsArray

:
: Object ModelSpace PaperSpace . Block
: PointsArray x,y,z .
: RetVal 3Dpolyline .
Closed True False
3Dpolyline .
:

Coordinate
Coordinates
. Length
.
AppendVertex )(
3Dpolyline :
3DplineObj.AppendVertex Point

:
: Point .
Explode
.
3Dpolyline .

:
command Form1 VBcad - 1
Add3Dpoly Caption Add3Dpoly Name

: Form1 Add3Dpoly - 2
Private Sub Add3Dpoly_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
'--------------------'2) Create a 3DPolyline object
Dim PolyObj As Acad3DPolyline
Dim Points(0 To 20) As Double
Points(0) = 5: Points(1) = 5: Points(2) = 0
Points(3) = 10: Points(4) = 5: Points(5) = 2
Points(6) = 10: Points(7) = 10: Points(8) = 4
Points(9) = 0: Points(10) = 10: Points(11) = 6
Points(12) = 0: Points(13) = 0: Points(14) = 8
Points(15) = 15: Points(16) = 0: Points(17) = 10
Points(18) = 15: Points(19) = 15: Points(20) = 12
Set PolyObj = Acadapp.ActiveDocument.ModelSpace.Add3Dpoly(Points)
Acadapp.ZoomExtents
Acadapp.ZoomScaled 0.75, acZoomScaledRelative
MsgBox "you have Create a 3DPolyline object"
'--------------------'3) Length of 3DPolyline object
Dim LenPoly As Double
LenPoly = PolyObj.Length
MsgBox "The Length Of 3DPolyline = " & LenPoly
'--------------------'4) Add new vertex To 3DPolyline object
Dim NewVertex(0 To 2) As Double
NewVertex(0) = 0: NewVertex(1) = 15: NewVertex(2) = 14
PolyObj.AppendVertex NewVertex
PolyObj.Update
MsgBox "you have add new Vertex to 3DPolyline = (0,15,14) "

'--------------------'5) Close the 3DPolyline object


PolyObj.Closed = True
PolyObj.Update
"MsgBox "you have Closed the 3DPolyline object
End Sub

:
-1 : Acadapp
.
-2 : PolyObj
3DPolyline
Points Add3Dpoly
ModelSpace . ActiveDocument
-3 : Length
.
-4 : AppendVertex
). (0,15,14
-5 : Closed
True .

You might also like