How can I select/find all objects in a circle?

Discussion in 'AutoCAD' started by Hartmut Callies, Aug 15, 2003.

  1. Hallo,
    I have drawing (ACAD2002) with a circle and any objects in the circle.
    With my vba-program I search all circles in the drawing. This part from
    the program work fine.
    Now I must select / find all objects in the circle - objects complete and
    incomplete in the circle. How can I do it with vba?

    Hartmut
     
    Hartmut Callies, Aug 15, 2003
    #1
  2. If you don't mind cheating ...

    You may be able to temporarily cross hatch the circle and then use the
    "IntersectWith" method to find anything that intersects with the cross
    hatch.

    Gary
     
    Gary McMaster, Aug 15, 2003
    #2
  3. 2) Approximate a circle with a series of short line segments and use
    This function will create a polyline with a given number of facets for a
    circle.
    http://groups.google.com/groups?q=facetcircle+group:autodesk.autocad.customi
    zation.vba

    You could try sending this polyline to the SelectByPolygon method. I've
    seen some people having problems with this method, but I don't know if it's
    still problematic.
    http://groups.google.com/groups?q=SelectByPolygon+group:autodesk.autocad.cus
    tomization.vba

    James
     
    James Belshan, Aug 15, 2003
    #3
  4. Hartmut Callies

    wivory Guest

    This would be my approach:
      1. Using the bounding box coordinates of the circle, do a "Select acSelectionSetCrossing" against the "square" that contains the circle.
      2. Iterate through the selection set doing an IntersectWith against the circle.
      2a. Any objects that get a "hit" are included.
      2b. Any objects that don't get a hit are either completely inside or completely outside the circle. For each object grab any point associated with it (eg vertex, centroid) and draw a ray through the centroid of the original circle. Then do an IntersectWith to see how many times the ray hits the circle. If it's an odd number of times then the object is within the circle and should be included in your result. (For completeness you should check that the arbitrary point on the object you choose is not in fact itself the centroid of the original circle, otherwise the ray approach will fail. Of course if it is the centroid then this object too is inside the circle.)
      
    Regards
      
    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, Aug 18, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.