| Author |
Message |
viswanathan
Guest
|
Posted:
Mon Dec 20, 2004 1:44 pm Post subject:
How to get the entityname in a closed polygon? |
|
|
Hi all,
I am having one closed polygon . Inside that polygon there is a text entity, Point entity etc....?
How to get the name of these all text and point entity inside a closed polygon?
Regards,
viswanathan.s
|
|
| Back to top |
|
 |
m8shark
Guest
|
Posted:
Mon Dec 20, 2004 10:36 pm Post subject:
Re: How to get the entityname in a closed polygon? |
|
|
What do you mean by entityname? That makes sense in lisp, but not really in VBA, where you would use the Handle (persistent) or ObjectID (transient).
You can process entities within a closed polygon with something like the following.
Sub Bubba()
Dim obj As AcadObject 'object selected with GetEntity
Dim vpt 'pick point for GetEntity
Dim vpts2 '2d array of lwpolyline coords
Dim vpts3() As Double '3d array of coords for selection set
Dim cnt As Integer 'count of lwpolyline coords
Dim i As Integer 'iterator variable
Dim ss As AcadSelectionSet
Dim ent As AcadEntity 'iterator object
'pick the lwpolyline
Utility.GetEntity obj, vpt
'must pick lwpolyline!
If Not TypeOf obj Is AcadLWPolyline Then Exit Sub
'convert 2d array to 3d array by first finding
'number of coordinates in lwpolyline. then create
'3d array with same number of coordinates and fill
'it with 2d array values
vpts2 = obj.Coordinates
cnt = (UBound(vpts2) + 1) / 2
ReDim Preserve vpts3((3 * cnt) - 1) As Double
For i = 0 To cnt - 1
vpts3(3 * i) = vpts2(2 * i) 'X
vpts3(3 * i + 1) = vpts2(2 * i + 1) 'Y
vpts3(3 * i + 2) = 0# 'Z
Next
'make/remake the selection set
On Error GoTo ErrHandler
Set ss = SelectionSets.Add("myss")
'fill the selection set
ss.SelectByPolygon acSelectionSetWindowPolygon, vpts3
'loop thru selection set and do stuff
For Each ent In ss
'do cool stuff here
Debug.Print ent.Handle
Next
'delete the selection set
ss.Delete
Exit Sub
ErrHandler:
If Err.Number = -2145320851 Then
SelectionSets("myss").Delete
Resume
End If
End Sub |
|
| Back to top |
|
 |
viswanathan
Guest
|
Posted:
Tue Dec 21, 2004 8:35 am Post subject:
Re: How to get the entityname in a closed polygon? |
|
|
Wow, Great. It is working fine.
Regards,
viswanathan.s
|
|
| Back to top |
|
 |
m8shark
Guest
|
Posted:
Tue Dec 21, 2004 9:07 am Post subject:
Re: How to get the entityname in a closed polygon? |
|
|
You're welcome.
Cheers, Steve |
|
| Back to top |
|
 |
|
|
|
|