Results 1 to 4 of 4

Thread: How to get the entityname in a closed polygon?

  1. #1
    viswanathan Guest

    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

  2. #2
    m8shark Guest
    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

  3. #3
    viswanathan Guest
    Wow, Great. It is working fine.

    Regards,

    viswanathan.s

  4. #4
    m8shark Guest
    You're welcome.

    Cheers, Steve

Similar Threads

  1. polygon resistance
    By mauricio in forum Cadence
    Replies: 4
    Last Post: 09-21-2005, 01:10 AM
  2. Replies: 2
    Last Post: 07-19-2005, 09:10 AM
  3. Shape to Polygon
    By tracy&amanda in forum Cadence
    Replies: 4
    Last Post: 03-13-2005, 02:47 PM
  4. Wipeouts to closed polylines
    By canon in forum Customization
    Replies: 6
    Last Post: 01-23-2005, 02:51 PM
  5. 2D Polygon generation w/VBA
    By postonz in forum VBA
    Replies: 3
    Last Post: 12-07-2004, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum