This is my code:
'---Selection set
Set poly_sset = ThisDrawing.SelectionSets.Add("SS_Price_Poly")
'Dim ftype(0) As Integer
Dim ftype(0) As Integer
Dim Fdata(0) As Variant
'---dxf code 0 = object type
ftype(0) = 0
'---filter for lwpolylines
Fdata(0) = "Lwpolyline"
'---get current selection
poly_sset.Select acSelectionSetPrevious, , , ftype, Fdata
'---is a polyline selected?
If poly_sset.Count <= 0 Then exit sub '---or put a error-msg here
'---if the user must select only one poly-line
If poly_sset.Count > 1 Then exit sub '---or errormsg "select only one
polyline"
Dim poly_ent As AcadEntity
Dim poly_coords As Variant '---or it is double?? variant
make no problems...
Set poly_ent = poly_sset.Item(0) '---if you are selecting more
than one polyline, you must create a loop and replace the (0) with a variable
poly_coords = poly_ent.Coordinates
'---numer of coords of poly
numer_of_points=ubound(poly_coords)-1 '---see NOTE !!
........
'---afert reading all the coordinates/polys delete the selection set---'
poly_sset.Clear
poly_sset.Delete
Set poly_sset = Nothing
End Sub
'---END---'
NOTE:
The last coordinate in he poly_coords() is the FIRST point of the poly-line!
(the position, at you begin drawin the polyline...and also the same as the first
point in the poly_coords() ).
I think, that this code is enought for you. 🙂
Bye
Paul Blaszczyk
My homepage: http://www.alpharay.de
-----------------------------------------------------------------------
Morgan Rauh wrotes:
> I am having the same problem as Paul. The polygon is a rectangle so I can
> get everything I need from the boundingbox. This code blithely returns 0,0,0
> and 0,0,0 as the two corners, which ofcourse, neither is. Help!!!
>
> mode = acSelectionSetCrossing
> gpCode(0) = 0
> dataValue(0) = "LWPOLYLINE"
>
> Dim groupCode As Variant, dataCode As Variant
> groupCode = gpCode
> dataCode = dataValue
>
> Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")
> ssetObj.Select mode, Pt1, Pt2, groupCode, dataCode
>
> Dim ent As AcadLWPolyline
> Dim BoxMin(0 To 2) As Double
> Dim BoxMax(0 To 2) As Double
> Set ent = ssetObj.item(0)
> 'ent.Delete [when this is online and the line below is not,
> indeed, the correct pline is deleted...]
> ent.GetBoundingBox BoxMin, BoxMax
>
> Is there a paper that lists all the changes to VBA in ACAD2K? Converting all
> our AutoCAD VB and VBA code is turning out to be unexpectly vexing. This
> problem is a great example. We want to upgrade our 50-100 users but...
>
> Help!
> Thanks