Create polyline from file

The VBA forum deals with IntelliCAD 2000 VBA (Visual Basic for Applications) issues.

Moderator: CMS Inc

Post Reply
MikeC
Newbie
Posts: 6
Joined: Sat Feb 24, 2007 12:01 am
Location: springville,utah,usa
Contact:

Create polyline from file

Post by MikeC » Tue Jul 10, 2007 10:26 am

Hello All,

I'm trying to create a ployline from a text file. I use a similar code to create lines from point to point. What is missing in this code? It appears to only create the first point in the file.



Do While Not EOF(1)

Input #1, number, XCOORD, YCOORD, ZCOORD, code

Set myPoints = Library.CreatePoints

Set pt = Library.CreatePoint(XCOORD, YCOORD, ZCOORD)

myPoints.Add

myPoints(myPoints.Count).x = pt.x

myPoints(myPoints.Count).y = pt.y

myPoints(myPoints.Count).z = pt.z


Loop
Close #1

Set myPline = ThisDocument.ModelSpace.AddPolyline(myPoints)

myPline.Update

ThisDocument.ActiveViewport.ZoomExtents


thanks MikeC
JohnF

Post by JohnF » Wed Jul 11, 2007 12:05 am

MikeC,

The problem may be 'Z' coordinates greater than zero in the text file.

You would need a 3DPolyline to be able to draw these.

I have created some VBA code as an example:

Sub TestPLine()
Dim myPLine As Polyline3D
Dim myPoints As Points
Dim x As Double
Dim y As Double
Dim z As Double
Dim I As Integer

'Start Values
x = 1
y = 2
z = 3


Set myPoints = Library.CreatePoints

'Loop Here
Do Until I = 10
myPoints.Add
myPoints(myPoints.Count).x = x
myPoints(myPoints.Count).y = y
myPoints(myPoints.Count).z = z

x = x + 10
y = y + 20
z = z + 30
I = I + 1
Loop

' Create 3D Polyline
Set myPLine = ThisDocument.ModelSpace.Add3DPoly(myPoints)
myPLine.Update


End Sub

Regards

John Finlay
MikeC
Newbie
Posts: 6
Joined: Sat Feb 24, 2007 12:01 am
Location: springville,utah,usa
Contact:

Create polyline from file

Post by MikeC » Wed Jul 11, 2007 11:45 am

John,

After looking at your code i moved "set mypoints=library.createpoints"
out of the do loop. works as planned now.

Thanks MikeC
Post Reply