×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Polylines

## Polylines

(OP)
Hello,

I'm runngin AutoCAD 2006 and have built an application with VBA. I've got the following code in my application in an attempt to create a six sided shape programmatically:

Private Sub cmdTest_Click()
Dim Points(5) As Double

Points(0) = 20: Points(1) = 20: Points(2) = 20
Points(3) = 20: Points(4) = 20

ZoomAll

End Sub

All I get is a straight line. What am I missing here? Any help is greatly appreciated.

Thanks,
T-Tops

### RE: Polylines

Hi,

Your points array is wrong. What you need is a 3 point array point for each vertex of the polyline.
For example the code below is for a rectangular polyline.
With any coordinate entry, VB requires at least 2 points in the array for each end point or start point etc - Point(0) refers to the X coordinate, Point(1) refers to the Y coordinate and Point(2) refers to the Z coordinate of each point and then Point(3) will refer to the X of the next point and so on. So make sure you point array is in multiples of either 2 or 3, so for a rectangle, you'll need an array of 12 in total - which is 0 to 11). 5 as you have will confuse the program..

#### CODE

Dim Points(0 to 11) As Double 'Declare the variable..
Points(0) = 0: Points(1) = 0: Points(2) = 0 'Start point..
Points(3) = 20: Points(4) = 0: Points(5) = 0 '2nd point..
Points(6) = 20: Points(7) = 20: Points(8) = 0 '3rd point..
Points(9) = 0: Points(10) = 0: Points(11) = 0 'End point..

Pline.Closed = True
ZoomAll

Some may debate whether you need the final point again, if you're going to Closed = True the polyline..

Also, note your line that creates the polyline itself, you need to set the variable name as the object not the object itself..

I hope i explained it ok, give me a shout if you need any more info..

Cheers,

Paul @ basepointdesignzltd..

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!