How to get the entityname in a closed polygon?
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
How to get the entityname in a closed polygon?

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
viswanathan
Guest





Posted: Mon Dec 20, 2004 1:44 pm    Post subject: How to get the entityname in a closed polygon? Reply with quote

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? Reply with quote

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? Reply with quote

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? Reply with quote

You're welcome.

Cheers, Steve
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB