Author Topic: VBA:Selecting two polylines with one click  (Read 3589 times)

0 Members and 1 Guest are viewing this topic.

ssaqibh

  • Guest
VBA:Selecting two polylines with one click
« on: January 01, 2014, 11:36:59 AM »
    I have two polylines with a common segment. With VBA I intend to click on the common segment and select both and assign them to two variables, tri1 and tri2

    Getentity for both requires two clicks.

    I have tried getentity followed by selectatpoint but selectatpoint is not always successful.

    Can someone give me a set of commands which can do this?

    Also posted on:
http://www.experts-exchange.com/Software/Photos_Graphics/CAD_Architecture/Q_28317360.html
http://forums.augi.com/showthread.php?153750-VBA-Selecting-two-polylines-with-one-click

n.yuan

  • Bull Frog
  • Posts: 348
Re: VBA:Selecting two polylines with one click
« Reply #1 on: January 02, 2014, 11:22:02 AM »
With VBA code, there are 2 ways to do it, as I can think of:

1. Use GetEntity() as you may already use. After getting the first polyline, you compare it with all other polylines in the drawing (of course, you can narrow down the polylines to be compared by creating a SelectionSet with a small window selecting around the picked point). Since the 2 polyline share a common segment, both polylines must have 2 equal vertices.

2. Use GetPoint() to pick a point that snaps to the common segement. Then create a temporary AcadPoint object and use IntersectWith() to find the 2 polylines.

To make things easier, can you just use AcadSelectionSet.SelectOnScreen()?

Cathy

  • Guest
Re: VBA:Selecting two polylines with one click
« Reply #2 on: January 02, 2014, 03:43:52 PM »
I have used AcadSelectionSet.SelectAtPoint to do something similar.  There is no reason to do a GetEntity first.  I'm not sure why your SelectAtPoint is not always successful.  Perhaps you need to set your osnap settings to nearest before the SelectAtPoint?
« Last Edit: January 02, 2014, 03:47:40 PM by Cathy »