- (defun c:gc (/ p1 p2 data n index)
- (setq p1 (ssget))
- (setq data())[color="green"] ;; you don't need this[/color]
- (setq n (sslength p1))
- (setq index 0)
- (repeat n
- (setq p2 (ssname p1 index))
- (setq data (append data p2))[color="green"] ; append is used with list, "data" variable is not a list
- ; this is where your error occurred [/color]
- (entmod data) [color="green"]; you don't need this[/color]
- (setq index (+ index 1))
- ) [color="green"]; repeat function ends without processing an entity[/color]
- (command "erase" p2 "")[color="green"] ;must be inside of the repeat function
- ;put this before you increment the index counter[/color]
- )
之后
- (defun c:gc (/ p1 p2 n index)
- (setq p1 (ssget))
- (setq n (sslength p1))
- (setq index 0)
- (repeat n
- (setq p2 (ssname p1 index))
- (command "erase" p2 "")
- (setq index (+ index 1))
- )
- (princ) ;exist cleanly
- )
|