+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12
  1. #11
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by nestly View Post
    Dang Alan, I wish I could write AutoLISP like that.
    Probably half the lisps I use were written by you.


    Here's one that will do both, WP (within polygon) and CP (crossing polygon). I had to go a different round that just using "CP" since just bogged the computer down stepping through all the created points (to account for Circles, Ellipses and arcs withing a polyline) and step through a crossing selection set of the bounding box of each selected object and see if it intersected with of the selected objects.

    Code:
    (defun c:SWC (/ _pac add ss i e temp it o a b pts tempC i3 ec)
      ;; Select Within/Crossing Curve
      ;; Alan J. Thompson, 03.31.11
    
      (vl-load-com)
    
      (defun _pac (e / l v d lst)
        (setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
        (while (< (setq d (+ d v)) l)
          (setq lst (cons (vlax-curve-getPointAtDist e d) lst))
        )
      )
    
      (initget 0 "Crossing Within")
      (setq *SWC:Opt*
             (cond ((getkword (strcat "\nSpecify selection method witin curve [Crossing/Within] <"
                                      (cond (*SWC:Opt*)
                                            ((setq *SWC:Opt* "Crossing"))
                                      )
                                      ">: "
                              )
                    )
                   )
                   (*SWC:Opt*)
             )
      )
    
      (princ "\nSelect closed curves to select object(s) within: ")
      (if (setq add (ssadd)
                ss  (ssget '((-4 . "<OR")
                             (0 . "CIRCLE,ELLIPSE")
                             (-4 . "<AND")
                             (0 . "*POLYLINE")
                             (-4 . "&=")
                             (70 . 1)
                             (-4 . "AND>")
                             (-4 . "OR>")
                            )
                    )
          )
        (progn (repeat (setq i (sslength ss))
                 (if (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i)))))))
                   (repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
                 )
    
                 (if (eq *SWC:Opt* "Crossing")
                   (progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'a 'b)
                          (setq pts (mapcar 'vlax-safearray->list (list a b)))
                          (if (setq tempC (ssget "_C"
                                                 (list (caar pts) (cadar pts) 0.)
                                                 (list (caadr pts) (cadadr pts) 0.)
                                          )
                              )
                            (repeat (setq i3 (sslength tempC))
                              (if (vlax-invoke
                                    o
                                    'Intersectwith
                                    (vlax-ename->vla-object (setq ec (ssname tempC (setq i3 (1- i3)))))
                                    acExtendNone
                                  )
                                (ssadd ec add)
                              )
                            )
                          )
                   )
                 )
               )
               (sssetfirst nil add)
               (ssget "_I")
        )
      )
      (princ)
    )
    I'm sure to get flamed shortly for posting all this code in the beginner area.
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  2. #12
    Forum Newbie
    Discipline
    Landscape
    Using
    AutoCAD 2016
    Join Date
    Feb 2018
    Posts
    1

    Default

    Registered forum members do not see this ad.

    Hi Alan,


    I was looking for a similar solution and I found this incredible solution. Could you please add a deselect option too just by clicking a polyline. It goes some thing like this :-
    So first step :
    User has the opportunity to select every thing/ or things he wants to select/ or by clicking a polyline to select every thing inside that closed polyline/ or crossing polyline selection.
    Second step: (User gets the opportunity to deselect any things he is already selected)
    User has the opportunity to deselect things he wants to deselect/ or by clicking a polyline to deselect every thing inside that closed polyline/ or crossing polyline deselection.
    May you please include this option too in the routine?


    Regards,
    VA

Similar Threads

  1. Use Quick Select to select objects in your AutoCAD drawing
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 16th Mar 2011, 04:29 pm
  2. line to poly
    By mart in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 5th May 2010, 01:36 pm
  3. How to select objects that touch a line?
    By M76 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 4th Feb 2010, 11:23 am
  4. Line and enclosed box Linetype HELP!
    By ALLI in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 6
    Last Post: 15th Jan 2009, 02:40 pm
  5. Quickly select objects with Quick Select
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 23rd Dec 2007, 01:13 am

Bookmarks

Posting Permissions

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