TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Adesu on June 21, 2007, 12:03:05 AM

Title: Why alls object remove
Post by: Adesu on June 21, 2007, 12:03:05 AM
Hi Alls,
Now you should create a rectangular, then extrude it, now use this code, but alls object remove, I want only one object stayed in
Code: [Select]
(defun c:test (/ cnt ss ssl ssn sso ssr ssx)
  (if
    (setq ss (car (entsel "\nSelect 3D objeck")))
    (progn
      (command "_explode" ss)
      (prompt "\nSelect alls object")
      (setq ssx (ssget))
      (prompt "\nSelect only one object")
      (setq sso (ssget))
      (setq ssr (ssname sso 0))
      (setq ssl (sslength ssx))
      (setq cnt 0)
      (repeat
ssl
(setq ssn (ssname ssx cnt))
(if
  (/= ssr ssn)
  (command "_erase" ssn "")
  ) ; if
(setq cnt (1+ cnt))
)   ; repeat
      )     ; progn
    (alert "\nInvalid selected object, please try again")
    )       ; if
  (princ)
  )         ; defun
Title: Re: Why alls object remove
Post by: HofCAD on June 21, 2007, 07:29:43 AM
Hi Adesu,

Why not

Code: [Select]
(defun c:test ( / ss ssr ssx)
  (if
    (setq ss (car (entsel "\nSelect 3D object for explode")))
    (progn
      (command "_explode" ss)
      (prompt "\nSelect all objects to remove")
      (setq ssx (ssget))
      (setq ssr (car (entsel "\nSelect only one object")))
      (command "_ERASE" ssx "R" ssr "")
    )       ; if
  (princ)
  )         ; defun

HofCAD CSI
Title: Re: Why alls object remove
Post by: Adesu on June 25, 2007, 07:46:41 PM
Hi HofCAD,
yes that is as alternative, thanks for yor share your code.


Hi Adesu,

Why not

Code: [Select]
(defun c:test ( / ss ssr ssx)
  (if
    (setq ss (car (entsel "\nSelect 3D object for explode")))
    (progn
      (command "_explode" ss)
      (prompt "\nSelect all objects to remove")
      (setq ssx (ssget))
      (setq ssr (car (entsel "\nSelect only one object")))
      (command "_ERASE" ssx "R" ssr "")
    )       ; if
  (princ)
  )         ; defun

HofCAD CSI