TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: xiaxiang on December 19, 2010, 08:36:22 PM

Title: Need help for ssget the line and the circle
Post by: xiaxiang on December 19, 2010, 08:36:22 PM
Recently I make a routine for ssget the line and the circle
Code: [Select]
 (setq ss1 (ssget '((0 . "LINE"))))
  (setq ss2 (ssget '((0 . "circle"))))
But I don't want to select twice,so I modify it
Code: [Select]
(setq sss (ssget  '((0 . "LINE,circle"))))  
but how can I Specify the entity of line to SelectionSet ss1,and the entity of circle to SelectionSet ss2?
I use the function http://www.theswamp.org/index.php?topic=20164.0 (http://www.theswamp.org/index.php?topic=20164.0) By Mr Ron.
And I use this routine to Cascade(connect) the Discrete lines and circles. I must Select Twice! Help me,thanks.
Title: Re: Need help for ssget the line and the circle
Post by: CAB on December 19, 2010, 08:58:33 PM
Look at this, it separates the ss1. Places circles in ss2. NOTE: no error handling.

Code: [Select]
(defun c:test ()
  (setq ss1 nil ss2 nil)
  (if (setq ss1 (ssget '((0 . "LINE,circle"))))
    (foreach itm (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))
      (if (= (cdr (assoc 0 (entget itm))) "CIRCLE")
        (progn
          (or ss2 (setq ss2 (ssadd)))
          (ssadd itm ss2)
          (ssdel itm ss1)
        )
      )
    )
  )
)
Title: Re: Need help for ssget the line and the circle
Post by: xiaxiang on December 19, 2010, 09:40:18 PM
Thank you Alan :-D
The code is updated.