Results 1 to 5 of 5

Thread: Selecting Entities

  1. #1
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Default Selecting Entities

    How can I select an entity with out prompting the user if I know a point which the object crosses.

    ThisDrawing.Utility.GetEntity selectObject, basePnt, "Select an object"

    This prompts the user. I already know what the basePnt is.

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Selecting Entities

    You cannot, with VBA. Can you take another approach?

  3. #3
    Active Member
    Join Date
    2000-12
    Location
    Las Vegas
    Posts
    68
    Login to Give a bone
    0

    Default Re: Selecting Entities

    You can create a selection set and then add to that selection set using the select method "SelectAtPoint" and then specify your point. This then will put your entity into the selection set as Item (0). you can then manipulate that entity by setting a dimensioned object as follows

    Dim SS as AcadSelectionSet
    Set SS = ThisDrawing.SelectionSets.Add("SS001")
    SS.SelectAtPoint(P1)
    Dim MyObj As AcadObject
    Set MyObj = SS.Item(0)
    SS.Delete

    MyObj is now the entity you wanted without prompting anyone for input because you know where P1 is and can define it.

    MyObj can now be moved, copies etc as an entity.
    You actually can dimension MyObj as what it really is like an entity or a 3D solid or Polyline, but using the object allows some flexibility if the object type is not always the same.

  4. #4
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Default Re: Selecting Entities

    That worked but now I have another issue. I am getting a mismatch type error when trying pull the AcadPolyLine out of the selection set.


    Public Function selectPolyLine(basePnt As Variant) As AcadPolyline
    Dim SS As AcadSelectionSet, myObj As AcadObject

    Set SS = ThisDrawing.SelectionSets.Add("SS001")
    SS.SelectAtPoint (basePnt)

    'Set myObj = SS.Item(0)
    'Set selectPolyLine = myObj
    Set selectPolyLine = SS.Item(0)
    SS.Delete
    End Function

  5. #5
    100 Club
    Join Date
    2000-11
    Location
    Adelaide, South Australia
    Posts
    116
    Login to Give a bone
    0

    Default Re: Selecting Entities

    Try this.
    Code:
     Public Function selectPolyLine(basePnt As Variant) As AcadPolyline
     Dim SS As AcadSelectionSet, myObj As AcadObject
     Set SS = ThisDrawing.SelectionSets.Add("SS001")
     SS.SelectAtPoint (basePnt)
     If SS.Count = 0 Then
     	MsgBox "Nothing was selected"
     Else
     	Set myObj = SS.Item(0)
     	If TypeOf myObj Is AcadPolyline Then
     		Set selectPolyLine = myObj
     	Else
     		MsgBox "Object is a " & myObj.ObjectName
     	End If
     End If
     SS.Delete
     End Function

Similar Threads

  1. Selecting nested entities in a block or xref
    By Coolmo in forum VBA/COM Interop
    Replies: 2
    Last Post: 2008-11-17, 03:57 PM
  2. Selecting entities and a send drawing new
    By fhuaylla in forum VBA/COM Interop
    Replies: 1
    Last Post: 2008-05-21, 04:36 PM
  3. Replies: 24
    Last Post: 2007-03-14, 06:00 AM
  4. Trouble selecting multiple entities in AutoCAD
    By jacobsondave in forum AutoCAD General
    Replies: 3
    Last Post: 2005-05-11, 02:15 AM
  5. Drawing slows down while selecting entities
    By jasontirone in forum AutoCAD General
    Replies: 1
    Last Post: 2005-03-29, 03:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •