Author Topic: Why alls object remove  (Read 2177 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
Why alls object remove
« 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

HofCAD

  • Guest
Re: Why alls object remove
« Reply #1 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
« Last Edit: June 21, 2007, 08:02:24 AM by HofCAD »

Adesu

  • Guest
Re: Why alls object remove
« Reply #2 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