e719 发表于 2023-11-2 09:10:15

大神们,帮忙解决一下这个复制到层问题

(defun M_FZ(layer2)
(setvar "cmdecho" 0)
(setq enn (ssget))
(setq n 0)
(repeat (setq nnn (sslength enn))
    (setq ent (ssname enn n))
(command "copy" ent "" "0,0" "0,0")
(setq ent (entlast))
(setq ent_data(entget ent))
(setq ent_data (subst (cons 8 layer2) (assoc 8 ent_data) ent_data ))
(entmod ent_data)
    (setq n (1+ n))
    )
)
(defun c:9V()(M_FZ "9") (M_FZ "99") (M_FZ "999") (M_FZ "9999")) (princ))


大神们,帮忙解决一下这个复制到层问题

这样需要选多好多次才能复制完成,能不能帮该成只选一次就能完成?

htlaser 发表于 2023-11-2 09:27:10

(defun M_FZ( enn layer2)
(setvar "cmdecho" 0)
(setq n 0)
(repeat (setq nnn (sslength enn))
    (setq ent (ssname enn n))
(command "copy" ent "" "0,0" "0,0")
(setq ent (entlast))
(setq ent_data(entget ent))
(setq ent_data (subst (cons 8 layer2) (assoc 8 ent_data) ent_data ))
(entmod ent_data)
    (setq n (1+ n))))
(defun c:9V(/ enn)
(setq enn (ssget))
        (M_FZ enn "9") (M_FZ enn "99") (M_FZ enn "999") (M_FZ enn "9999") (princ))

e719 发表于 2023-11-2 09:40:50

htlaser 发表于 2023-11-2 09:27
(defun M_FZ( enn layer2)
(setvar "cmdecho" 0)
(setq n 0)


十分感谢,这就是我想要的

htlaser 发表于 2023-11-2 10:22:30

(defun M_FZ( enn layer2)
(setq n 0)
(repeat (setq nnn (sslength enn))
    (setq ent (ssname enn n))
(command "copy" ent "" "0,0" "0,0")
(setq ent (entlast))
(setq ent_data(entget ent))
(setq ent_data (subst (cons 8 layer2) (assoc 8 ent_data) ent_data ))
(entmod ent_data)
    (setq n (1+ n))))
(defun c:9V (/ cmd enn osm)
      (setq osm (getvar "osmode"))
      (setq cmd (getvar "cmdecho"))
      (setvar "osmode" 0)
      (setvar "cmdecho" 0)
(setq enn (ssget))
      (M_FZ enn "9") (M_FZ enn "99") (M_FZ enn "999") (M_FZ enn "9999")
      (setvar "osmode" osm)
      (setvar "cmdecho" cmd)      
      (princ))

xyp1964 发表于 2023-11-2 21:01:38


(defun c:tt ()
(defun M_FZ (ss la / s0 ss1)
    (setq s0 (entlast))
    (setvar 'clayer la)
    (command "copy" ss "" "0,0" "0,0")
    (setq ss1 (ssadd))
    (while (setq s0 (entnext s0))
      (ssadd s0 ss1)
    )
    (command "chprop" ss1 "" "la" la "")
)
(if (setq ss (ssget))
    (mapcar '(lambda (x) (M_FZ ss x)) '("9" "99" "999" "9999"))
)
(princ)
)
页: [1]
查看完整版本: 大神们,帮忙解决一下这个复制到层问题