POLYLINE

POLYLINE

Anonymous
Not applicable
802 Views
10 Replies
Message 1 of 11

POLYLINE

Anonymous
Not applicable
I have a richtext box that has contains

X,Y
X,Y
X,Y
X,Y
X,Y

and I would like to create a polyline from the X,Y's in the richtextbox.

Any Ideas? It needs to be a continuas polyline.
0 Likes
803 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
I'd bet the appropriate method has Polyline in its name and guarantee there is a sample in the
help menu... So I assume that's not your question - what exactly are you having trouble with?

wrote in message news:5870481@discussion.autodesk.com...
I have a richtext box that has contains

X,Y
X,Y
X,Y
X,Y
X,Y

and I would like to create a polyline from the X,Y's in the richtextbox.

Any Ideas? It needs to be a continuas polyline.
0 Likes
Message 3 of 11

Anonymous
Not applicable
I am having trouble asigning all of the X,Y's to the POLYLINE and then drawing the long polyline?
0 Likes
Message 4 of 11

Anonymous
Not applicable
I won't guess - post the relevant code...

wrote in message news:5870483@discussion.autodesk.com...
I am having trouble asigning all of the X,Y's to the POLYLINE and then drawing the long polyline?
0 Likes
Message 5 of 11

Anonymous
Not applicable
Set ObjPolyline = Thisdrawing.modelspace.AddPolyline (Richtextbox1.text)


Note: The RichTextbox is multiline and the contents are

X,Y
X,Y
X,Y
X,Y
X,Y
X,Y

I also have a string named TEMPSTRING
TEMPSTRING = X,Y,X,Y,X,Y,X,Y,X,Y

The above doesn't work.
I need a continuous polyline using either the Richtextbox1.text contents OR by using the TempString
0 Likes
Message 6 of 11

Anonymous
Not applicable
I think I need to create an point array from the TEMPSTRING or TEXTBOX but I don't know how.
0 Likes
Message 7 of 11

Anonymous
Not applicable
Try this one

Option Explicit
Dim ar As Variant

Private Sub CommandButton2_Click()
Dim st As String
st = RichTextBox1.Text
ar = Split(st, vbCr)
ReDim Preserve ar(UBound(ar) - 1)
Dim cnt
Dim i
ReDim coors(0 To (UBound(ar) * 2) + 1) As Double
For i = 0 To UBound(ar)
Dim tmp
tmp = Split(ar(i), ",")
coors(cnt) = CDbl(tmp(0))
cnt = cnt + 1
coors(cnt) = CDbl(tmp(1))
cnt = cnt + 1
Next i
ThisDrawing.ModelSpace.AddLightWeightPolyline coors
End Sub

~'J'~
0 Likes
Message 8 of 11

Anonymous
Not applicable
[code]
Sub driver()

Dim pl As AcadLWPolyline
Set pl = ThisDrawing.ModelSpace.AddLightWeightPolyline _
(StringToDoubleArray("1,1,2,2,0,2"))
pl.Closed = True

End Sub


Function StringToDoubleArray(inString As String)
'you could avoid using split and just loop
'the string but you would need to keep calling
'redim. Would be good practice to try looping
'the string though. Look into VBA.Mid, VBA.Len, ...
Dim strArr
strArr = VBA.Split(inString, ",")

ReDim dblArr(UBound(strArr)) As Double

Dim i As Integer
For i = 0 To UBound(strArr)

If VBA.IsNumeric(strArr(i)) Then
dblArr(i) = strArr(i)
Else
'Solve the problem
End If

Next i

StringToDoubleArray = dblArr

End Function
[/code]

wrote in message news:5870504@discussion.autodesk.com...
Set ObjPolyline = Thisdrawing.modelspace.AddPolyline (Richtextbox1.text)


Note: The RichTextbox is multiline and the contents are

X,Y
X,Y
X,Y
X,Y
X,Y
X,Y

I also have a string named TEMPSTRING
TEMPSTRING = X,Y,X,Y,X,Y,X,Y,X,Y

The above doesn't work.
I need a continuous polyline using either the Richtextbox1.text contents OR by using the TempString
0 Likes
Message 9 of 11

Anonymous
Not applicable
You could also use a Collection as your container which dynamically resizes itself.
This version would also take any or no delimiter.

[code]
Function StringToDoubleArray(inString As String) As Double()
Dim dblColl As New Collection

Dim i As Integer
For i = 0 To VBA.Len(inString)
If VBA.IsNumeric(VBA.Mid(inString, i + 1, 1)) Then
dblColl.Add VBA.Mid(inString, i + 1, 1)
End If
Next i

ReDim scratch(dblColl.Count - 1) As Double
For i = 0 To dblColl.Count - 1
scratch(i) = dblColl(i + 1)
Next i

StringToDoubleArray = scratch

End Function
[/code]

"Paul Richardson" wrote in message news:5870497@discussion.autodesk.com...
[code]
Sub driver()

Dim pl As AcadLWPolyline
Set pl = ThisDrawing.ModelSpace.AddLightWeightPolyline _
(StringToDoubleArray("1,1,2,2,0,2"))
pl.Closed = True

End Sub


Function StringToDoubleArray(inString As String)
'you could avoid using split and just loop
'the string but you would need to keep calling
'redim. Would be good practice to try looping
'the string though. Look into VBA.Mid, VBA.Len, ...
Dim strArr
strArr = VBA.Split(inString, ",")

ReDim dblArr(UBound(strArr)) As Double

Dim i As Integer
For i = 0 To UBound(strArr)

If VBA.IsNumeric(strArr(i)) Then
dblArr(i) = strArr(i)
Else
'Solve the problem
End If

Next i

StringToDoubleArray = dblArr

End Function
[/code]

wrote in message news:5870504@discussion.autodesk.com...
Set ObjPolyline = Thisdrawing.modelspace.AddPolyline (Richtextbox1.text)


Note: The RichTextbox is multiline and the contents are

X,Y
X,Y
X,Y
X,Y
X,Y
X,Y

I also have a string named TEMPSTRING
TEMPSTRING = X,Y,X,Y,X,Y,X,Y,X,Y

The above doesn't work.
I need a continuous polyline using either the Richtextbox1.text contents OR by using the TempString
0 Likes
Message 10 of 11

Anonymous
Not applicable
Thanks everyone but I still doesn't seem to work. Instead of my program building a string or populating a richtextbox is there a way to have it populate an array? vars = XXX and YYY
0 Likes
Message 11 of 11

Anonymous
Not applicable
Thank you all. Got it to work with a little editing.

God bless
0 Likes