I'm trying to extract information from a closed polyline (old style, not
lightweight poly's). When I read the bulge for the last vertex (using
GetBulge()), I get an Out Of Range error.
For example:
vertexCnt = 5
for i = 0 to VertexCnt - 1
bulge = pline.GetBulge(i)
....
....
next i
Questions:
1) Is there another way to get the bulge for the last vertex? (BTW, the
above codes works just fine for Lightweight Polylines.
2) If not, then how do you determine if the closing leg is an arc or a line
if you can't get the bulge?
3) If it is an arc, how do you calculate it without the bulge?
Any ideas?
Dale Derix
Emerald Data, Inc.
s...@worldnet.att.net
I too would be interested in an answer.
Alan
al...@awol.demon.co.uk
al.wi...@taywood.co.uk
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Here's still hoping....
Dale Derix
Emerald Data, Inc.
s...@worldnet.att.net
<al.wi...@taywood.co.uk> wrote in message
news:7nrq4k$3kp$1...@nnrp1.deja.com...
Denis
Sure,
the following routine will let you select a polyline, or lightweight
polyline and then step through the coordinates and bulge for each vertex
(showing a message for each one). Note that the problem occurs only with the
older polylines (of type acPolyline). Not the newer lightweight polylines.
I'm using R14.01.
I really appreciate your taking the time to take a look at this.
Dale
********* code follows ************
'
' Debug routine to illustract problem with extracting info for polylines.
' To use, run this macro, select a polyline with mouse, then hit enter.
'
Public Sub ListVertex2()
Dim i As Integer
Dim j As Integer
Dim coords As Variant
Dim CoordCnt As Integer
Dim sset As AcadSelectionSet
Dim Typ As Integer
Dim x As Double
Dim y As Double
Dim z As Double
Dim blge As Double
Set sset = ThisDrawing.SelectionSets.Add("SS")
sset.SelectOnScreen 'Get a polyline
Typ = sset.Item(0).EntityType
If Typ = acPolyline Then
coords = sset.Item(0).Coordinates
CoordCnt = UBound(coords) + 1
i = 0
j = 0
While i < CoordCnt
x = coords(i) 'get coords (acPolyline has x,y,z)
y = coords(i + 1)
z = coords(i + 2)
i = i + 3
blge = sset.Item(0).GetBulge(j) '<<<ERROR WILL OCCUR HERE ON
LAST VERTEX>>>
j = j + 1
MsgBox "Vertex " & Str$(j) & " x=" & Str$(x) & ", y=" & Str$(y) &
", z=" & Str(z) & ", B=" & Str$(blge)
Wend
ElseIf Typ = acPolylineLight Then 'Lightweight polyline version....
this works fine
coords = sset.Item(0).Coordinates
CoordCnt = UBound(coords) + 1
i = 0
j = 0
While i < CoordCnt
x = coords(i) 'get coords (acPolylineLight only has
x,y)
y = coords(i + 1)
i = i + 2
blge = sset.Item(0).GetBulge(j)
j = j + 1
MsgBox "Vertex " & Str$(j) & " x=" & Str$(x) & ", y=" & Str$(y) &
", B=" & Str$(blge)
Wend
End If
End Sub
Your code works fine on all my polylines ( 2D and LW )
You'll have to extract and send a piece of your drawing including the
defective polyline
Denis
hth
thomas
Dale Derix schrieb:
I've tested your code and it works at 2000 but, yes at R14.01
it bombs when trying to get the bulge for the last vertex in
an "old style" polyline".
Sorry I couldn't be of more help.
Alan
Sorry, every vertex has a bulge - it's just 0 in some cases
Alan
In article <37A582C6...@nospam.gmx.net>,
thomas...@nospam.gmx.net wrote:
> as the polyline ends with the last vertex, a bulge value (telling how
to
> continue)
> makes no sense there.
>
> hth
>
> thomas
>
Sent via Deja.com http://www.deja.com/
Try this scenario,
1. Create a polyline, with the first two legs as lines.
2. Now switch to arc mode and create a arc.
3. Now type CL to close the polyline.
You now have two lines, and two arcs. The list command confirms this, and
shows the bulge values for both of the arcs, including the last one that
draws the arc back to the polyline starting point. However, GetBulge can't
seem to find it.
I've attached a small drawing that illustrates this in a previous post.
Dale
Thomas Heilig <thomas...@nospam.gmx.net> wrote in message
news:37A582C6...@nospam.gmx.net...
> as the polyline ends with the last vertex, a bulge value (telling how to
> continue)
> makes no sense there.
>
> hth
>
> thomas
>
Dale Derix a écrit dans le message <7o49lp$i5...@adesknews2.autodesk.com>...
>Denis-
>
>I've attached a sample dwg showing the problem. Is is possible that this
>drawing is somehow corrupt?
>
>Thanks,
>Dale
>
>
>Denis Gagné <de...@videotron.ca> wrote in message
>news:7o22n6$ev...@adesknews2.autodesk.com...
Thanks for following this through. This helps narrow my search for answer.
BTW, what version of AutoCAD are you using?
Many Thanks,
Dale
Denis Gagne <de...@videotron.ca> wrote in message
news:7o4aqo$i5...@adesknews2.autodesk.com...
A2K build version T.0.98
I just tried reading the polyline in A2K as well with no problems. I then
modified the MsgBox statements in the vba that I sent you to indicate which
poly type was being processed....... A2K apparently converts it to a
LWpolyline, which works just fine. The list command confirms this.
So... could this be a buge with R14?
I have not used or programmed AutoCAD in many years... Is there a buglist
available that I can check to see if this may be the case?
Dale
Denis Gagne <de...@videotron.ca> wrote in message
news:7o4e5t$i5...@adesknews2.autodesk.com...
every vertex has a bulge value (even if it is zero) which is important
to describe how to continue from that point.
It is neccessary if yout pline is closed, because then, the real
last vertex is equal the point value of the first.
Thanks for the detail
Thomas
Each bulge defines the curvature of the segment
that connects it with the following vertex, and
the last bulge is only significant if the polyline
is closed, in which case, it describes the last
segment (the one that connects the last vertex to
the first).
--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.t...@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
In trying to process polylines for my app, I get an "out of range" error
when attempting to read the bulge for the last segment of a closed polyline
of type acPolyline (not Lightweight... lightweight polylines work fine.).
This problem occurs in R14.01 but not in Acad2000. Do you have any insight
as to what's happening here, or what I'm doing wrong.
I've posted sample code earlier in this thread.
Thanks,
Dale Derix
Emerald Data, Inc.
s...@worldnet.att.net
Tony Tanzillo <tony.t...@worldnet.att.net> wrote in message
news:37AAA928...@worldnet.att.net...
> You seem to be confusing vertices and segments.
>
> Each bulge defines the curvature of the segment
> that connects it with the following vertex, and
> the last bulge is only significant if the polyline
> is closed, in which case, it describes the last
> segment (the one that connects the last vertex to
> the first).
>
--