PDA

View Full Version : Polyline vs. Lightweight Polyline



lillian.twining
2005-12-30, 03:01 PM
Why do you have to enter 3 coordinates for every point when drawing a polyline, if the z coordinate has no effect on the location of the polyline? No matter what z coordinate I enter, the polyline is still drawn at the 0 Z coordinate. Atleast in lightweight polylines, it does the same thing, but you only have to enter 2 coordinates for every point. Let me know if anyone has any ideas. I've included an example incase this doesn't make any sense.


'Select Points
ReDim dblPoints(17)
dblPoints(0) = 0: dblPoints(1) = 0: dblPoints(2) = 10 '<-----This number seems to have no effect on the actual polyline
dblPoints(3) = 12: dblPoints(4) = 0: dblPoints(5) = 10
dblPoints(6) = 15.68: dblPoints(7) = 11.43: dblPoints(8) = 100
dblPoints(9) = 6: dblPoints(10) = 18.43: dblPoints(11) = 1000
dblPoints(12) = -3.68: dblPoints(13) = 11.43: dblPoints(14) = 10000
dblPoints(15) = 0: dblPoints(16) = 0: dblPoints(17) = 0

'Draw the LightWeightPolyline
Set objLWPolyLine = ThisDrawing.ModelSpace.AddPolyline(dblPoints)

[ Moderator Action = ON ] Code is easier to read with [ CODE ] (http://forums.augi.com/misc.php?do=bbcode#code) tags... [ Moderator Action = OFF ]

Jeff_M
2005-12-30, 03:41 PM
Hi Lilian,
Here's some test code to demonstrate the differences.....note how the LWpline is completely different, since it only uses x/y values the first z becomes the second x......also the help file says for polylines:

An array of OCS coordinates used to create the polyline vertices. Each vertex is represented with three elements, with the first two being the X and Y coodinates in OCS; the third element is ignored. At least two points (six elements) are required for constructing a polyline object. The array size must be a multiple of three.
So to set the elevation, use the Elevation property.


Sub pline_test()
Dim dblPoints(17) As Double
Dim objLWPolyline As AcadLWPolyline
Dim obj2dPline As AcadPolyline
Dim obj3dPline As Acad3DPolyline
Dim pt1(2) As Double
Dim pt2(2) As Double

dblPoints(0) = 0: dblPoints(1) = 0: dblPoints(2) = 10 '<-----This number seems to have no effect on the actual polyline
dblPoints(3) = 12: dblPoints(4) = 0: dblPoints(5) = 10
dblPoints(6) = 15.68: dblPoints(7) = 11.43: dblPoints(8) = 100
dblPoints(9) = 6: dblPoints(10) = 18.43: dblPoints(11) = 1000
dblPoints(12) = -3.68: dblPoints(13) = 11.43: dblPoints(14) = 10000
dblPoints(15) = 0: dblPoints(16) = 0: dblPoints(17) = 0

'Draw the LightWeightPolyline
Set objLWPolyline = ThisDrawing.ModelSpace.AddLightWeightPolyline(dblPoints)
pt2(1) = 25#
objLWPolyline.Color = acRed
objLWPolyline.Move pt1, pt2

Set obj2dPline = ThisDrawing.ModelSpace.AddPolyline(dblPoints)
pt2(1) = -25#
obj2dPline.Color = acGreen
obj2dPline.Move pt1, pt2

Set obj3dPline = ThisDrawing.ModelSpace.Add3DPoly(dblPoints)

End Sub

RobertB
2006-01-03, 07:58 PM
Lillian, that is due to the legacy nature of the old heavyweight polylines vs. the lightweight polylines. The vertex data on heavyweight polylines was always stored as a 3D point, even though the polyline's vertices could not have different Z coordinates.

LWPolylines were created to permit much of the same behavior as the legacy polylines, while using a more efficent data storage scheme.