You are on page 1of 5

AutoCAD

AutoCAD 2000 VBA

VBA
VBA Editor VB .
VBA(Visual Basic Application) VB(Visual Basic) AutoCAD 2000 .
, VBA AutoCAD , ,
AutoCAD 2000 AutoCAD R14 InteliCAD .
, , , , .

VBA

, VBA

, AutoCAD

VB VB AutoCAD
AutoCAD .

.
VBA Lisp ObjectARX

VBA Editor
AutoCAD 2000 VBA Editor Tools\Macro
\Visual Basic Editor ALT+F11 .

Editor View Menu


. AutoCAD Projects .

VBA (, , )
AutoCAD Object

Forms
Standard modules
Class modules
References

AutoCAD Projects *dvb CAD


.
1. Visual Basic

Project Explorer
Project Explorer Window Forms, Code
Modules, Class Modules . < 2>

Project Explorer Window Open


View|Project Explorer
Ctrl+R .

Project .
2. Project Explorer

/ RBS . E-Mail fly2820@rbseng.co.kr

138 3 2000/8

AUTOCAD

Code Window
Code Window VBA Editor
Code Widow . Code
. View\Code F7 .

3. Code Window

Properties Window
. Form , ,
.

4. Propeties Window

Standard Modules
Standard Modules
, , Data Type, .
. Degrees Radians

Public Function DegreesToRadians(Degrees As Double) As Double


DegreesToRadians = (dblPi * Degrees)/180
End Function

, .

Class Modules
Class Modules ,
Method, Property, Events .

Code , Line
Property Code Line .

, Line Object Method

Objects and Classes


Objects Classes . Objects Class
Instances . Class Length, Width, Height
Property Add, Delete Method .
Class Instance Property

Dim objMyNewObject as New clsMyObject

clsMyObject class Object ,


objMyObject .

2000/8 3139

AutoCAD

Property
Object Property .
Line StartPoint Property Position

, Color Property Red .


Line .

dblStartPoint = objLine.StartPoint
MsgBoxThe Line begins as & dblStartPoint(0) &, &
dblStartPoint(1) & _
. 5

, & dblStartPoint(2)
dbjLine.Color = acRed

Methods
Object ,
Property Object Method
. AddCircle method ModelSpace
Circle object .

.
dblCenterPoint (0) = 0#
dblCenterPoint (0) = 0#
dblCenterPoint (0) = 0#
dblRadius = 2#

Dim objCircle As AcadCircle

Dim dblCenterPoint (0 to 2) As Double

Set objcircle=ThisDrawing.ModelSpace.AddCircle(dblCenterPoint,

Dim dblRadius As Double

dblRadius)

Events
Event , , .

a=1 b=0, a=1 b=1. else

If
If <> then

. a=1 b=0.

Select case
If a=1 then b=0
Select case a a ,

If a=1 then
b=0

case 1
b=1
case 2

End if

b=2
.

If Then else End If

.
.

If a=1 then
b=0

case else
b=3
End select

esle
b=1
end if

a 1 b=1, 2 b=2, a b
3. case else .

140 3 2000/8

AUTOCAD

(Loop)
For Next

Do
For a=1 To 10 Step 2
b=a+b
Next a

<>
Loop <>
<> .

a 1 10 2 10

While <> : False

. b 25. Step , Step 1

Until <> : True

.
Do Until a>=10
a=a+1

Do Loop

b=a+b

Do Loop 2 .

(If a>10 Exit Do)


Loop

Do <>
<>
Loop

, a 10 , b=55
. Until Loop Do
. If Do Loop .

For Next
: Dim, Static
: Dim, Private, Public


Dim Data1 As Integer

Data1 () .


Dim Data1 As Integer

Data1 , Data1
.
Static Data1 As Integer

Data1 (

.
Private Data1 As Integer( )

Dim Public .
Public Data1 As Integer

Data1 () .
.

) .


, 0 100

. , 0 100

, ,

2000/8 3141

AutoCAD

< 1> VB

Byte

0255

Boolean

True False

Integer

-32,76832,767

Long

-2,147,483,648 ~2,147,483,647

&

Single

Double

Currency

-922,337,203,685,477.5808922,337,203,685,477.5807

Date

100 1 19999 1031

: -3.402823E38-1.401298E-45

: 1.451298E-453.402823E38
:-1.79769313486232E308-4.94065645841247E-324

:4.94065645841247E-3241.79769313486232E308

Object

String

1- 65,400

Variant

: Double
: 22 +

A .

,
1

. A .
A(0)=1
A(1)=2
A(2)=3
A(3)=4

,
A(1,1)=2
A(1,2)=4
A(2,1)=3
, .


A , 4 5
, 3 6
, 3 , 5 2 7
, Single. A(0,0) .
Dim A(3 , 4) As Integer
Dim A(3 to 5, 2 to 7) As Single


.
Dim A(0 To 3, 0 To 4) As Single

VBA VB .
AutoCAD Object ,
AutoCAD .

142 3 2000/8


1 VBA

5 Drawing Objects

2 The Object Model

6 VBA Project

3 AutoCAD

7 Excel VBA

4 Layers Linetypes

You might also like