Lee Mac 发表于 2022-7-6 16:28:20

好的,局部变量:
 

; Lxplode by ASMI - modified slightly (and hopefully correctly) by Lee McDonnell

(defun c:lxplode2 (/ ss ssl index eEnt cLay lEnt cDxf nDxf)
   (setq ss (ssget))
   (if    (/= (setq ssl (sslength ss)) nil)
   (progn
       (setq index 0)
       (repeat ssl
       (setq eEnt (ssname ss index)
             cLay (cdr (assoc 8 (entget eEnt)))
             lEnt (entlast)
       ) ; end setq
       (if (and
         (vl-cmdf "_.explode" eEnt)
         (not (equal lEnt (entlast)))
         ) ; end and
         (progn
         (while (setq lEnt (entnext lEnt))
               (setq cDxf (entget lEnt)
               nDxf (subst (cons 8 cLay) (assoc 8 cDxf) cDxf)
               ) ;_end setq
               (entmod nDxf)
         ) ; end while
         (princ (strcat "\nEntities exploded onto layer " cLay "."))
         ) ; end progn
         (princ "\n<!> Can't explode this entity <!> ")
       ) ; end if
       (setq index (1+ index))
       ) ;_end repeat
   ) ;_end progn
   (princ "\nNo Entities Selected!")
   ) ;_end if
   (princ)
) ; end of c:lxplode2

页: 1 [2]
查看完整版本: 层分解