xstlf 发表于 2004-12-17 16:27:00

<A name=63307><FONT color=#990000><B>meflying</B></FONT></A>老师,我试过,Copy的话,若选择多个实体进行copy。只会把多个实体中的最后一个变成当前层的,若让多个实体一起变成当前层,应该用什么方法呀?

332888 发表于 2004-12-22 14:27:00

在网路上找到的试试看


(defun C:` (/ SS FLS ENT CL) ;复制层(`在esc键下方) <BR>(vl-load-com) <BR>(command "_.ucs" "")


(prompt "\Copy * Layer") <BR>(setq SS (ssget)) <BR>(setq FLS (LAYERR)) <BR>(setq CL (getvar "clayer")) <BR>(foreach ENT FLS <BR>(setq ENT (vl-princ-to-string ENT)) <BR>(if (not (tblsearch "layer" ENT)) <BR>(command "layer" "m" ENT "") <BR>) <BR>(command "copy" SS "" "0,0" "0,0") <BR>(command "change" SS "" "P" "la" ENT "") <BR>) <BR>(command "_.ucs" "p") <BR>(setvar "clayer" CL) <BR>(prin1) <BR>) <BR>(defun LAYERR (/ AJS FLS WORD LST1 N) <BR>(setq AJS (getstring "\n输入层名/(选择图层) :") <BR>LST1 "" <BR>N 1 <BR>) <BR>(if (= AJS "") <BR>(setq FLS (list (cdr (assoc 8 (entget (car (entsel))))))) <BR>(progn <BR>(repeat (strlen AJS) <BR>(setq WORD (substr AJS N 1)) <BR>(if (not (equal "," WORD)) <BR>(setq LST1 (strcat LST1 WORD)) <BR>(progn <BR>(setq FLS (append FLS (list LST1)) <BR>LST1 "" <BR>) <BR>) <BR>) <BR>(setq N (1+ N)) <BR>) <BR>(if (not (equal LST1 "")) <BR>(setq FLS (append FLS (list LST1))) <BR>FLS <BR>) <BR>) <BR>) <BR>)

jeepsheep 发表于 2004-12-26 23:38:00

能否不输图层名吗?哪能记得这么多!直接变成当前层多好,要不就做成对话框选图层!

andyding 发表于 2005-3-3 20:22:00

我也来凑下热闹!!!


我用最简间的办法做.


(DEFUN C:CU() (setq pp (ssget))<BR>                                                                                                       (setq LAY (getvar "CLAYER"))<BR>                                                                                                       (COMMAND "COPY" pp "" "0,0" "0,0")<BR>                                                                                                       (COMMAND "CHPROP" "P" "" "LA" lay "LT" "bylayer" "C" "bylayer" "")(princ))                                                                                                               <BR>(DEFUN C:OC() (vl-cmdf "_.undo" "_group")<BR>                                                                                                       (mapcar 'princ (list "Current offset dist= " (getvar "OFFSETDIST")" "))<BR>                                                                                                       (setq di (getstring "\nEnter Offset Dist:"))<BR>                                                                                                       (setq o (ssget))<BR>                                                                                                       (setq po (getpoint "\nSide to offset")) <BR>                                                                                                       (setq LAY (getvar "CLAYER"))<BR>                                                                                                       (if (/= di nil)<BR>                                                                                                       (COMMAND "OFFSET" di o po "")<BR>                                                                                                       (COMMAND "CHPROP" "L" "" "LA" lay "LT" "bylayer" "C" "bylayer" ""))<BR>                                                                                                       (if (= di nil)<BR>                                                                                                       (COMMAND "OFFSET" "" o po "")<BR>                                                                                                       (COMMAND "CHPROP" "L" "" "LA" lay "LT" "bylayer" "C" "bylayer" ""))<BR>                                                                                                       (vl-cmdf "_.undo" "_end")(princ))

山姆 发表于 2005-3-23 23:56:00

andyding发表于2005-3-3 20:22:00static/image/common/back.gif我也来凑下热闹!!!



我用最简间的办法做.


(DEFUN C:CU() (setq pp (ssget))                                                                                                       (setq LAY (getvar \"CLAYER\"))                                                                                                       (COMMAND \"C...

<BR>这两个程序好用,好好用,非常感谢

Gu_xl 发表于 2005-4-1 12:42:00

偏移到当前层命令:


(defun C:CLoffset (/ d dt e cl p cm nt)<BR>               (setierr)<BR>               (setq d (getvar "offsetdist")<BR>                                                               cl (getvar "clayer")<BR>                                                               )<BR>               (if (&gt; d 0) (setq ds (rtos d 2) dt nil)<BR>                                                                                                               (setq ds "Through" dt t)<BR>                                               )<BR>               (initget 7 "Through       ")               <BR>               (setq d1 (getdist (strcat "\nOffset distance" "&lt;" ds "&gt; :")))<BR>               (if (= d1 "Through") (setq dt t)<BR>                                               (if (= d1 "") (if dt () (setq d1 d)) (setq dt nil))<BR>                                               )       <BR>               (initget 7 "       ")       <BR>               (setq e (entsel "\nSelect object to offset :"))<BR>               (while (not e)<BR>                                                                               (initget 7 "       ")<BR>                                                                               (setq e (entsel "\nSelect object to offset :"))<BR>                                                       )<BR>               (if (= e "")<BR>                                               (abcdefg)<BR>                                               (redraw (car e) 3)<BR>                               )<BR>               (setq p (getpoint "\nSide to offset?"))<BR>               (if dt (command ".offset" "T" e p "") (command ".offset" d1 e p ""))<BR>               (redraw (car e) 4)<BR>               (command "_change" (entlast) "" "p"       "La" cl "c" "Bylayer" "lt" "bylayer" "")<BR>               (setq nt t)<BR>               (while nt<BR>                                                       (initget 7 "       ")<BR>                                                       (setq e (entsel "\nSelect object to offset :"))<BR>                                                       (while (not e)<BR>                                                                               (initget 7 "       ")<BR>                                                                               (setq e (entsel "\nSelect object to offset :"))<BR>                                                                       )<BR>                                                       (if (= e "") (setq nt nil)<BR>                                                                                       (progn<BR>                                                                                                                                       (redraw (car e) 3)<BR>                                                                                                                                       (setq p (getpoint "\nSide to offset?"))<BR>                                                                                                                                       (if dt (command ".offset" "T" e p "") (command ".offset" d1 e p ""))<BR>                                                                                                                                       (command "_change" (entlast) "" "p"       "La" cl "c" "Bylayer" "lt" "bylayer" "")<BR>                                                                                                                                       (redraw (car e) 4)<BR>                                                                                                               )<BR>                                                                       )<BR>                                       )<BR>        <BR>                                                       <BR>               (reerr)<BR>               (princ)<BR>        )


       

Gu_xl 发表于 2005-4-1 12:43:00

(defun C:CLoffset (/ d dt e cl p cm nt)<BR>               (setierr)<BR>               (setq d (getvar "offsetdist")<BR>                                                               cl (getvar "clayer")<BR>                                                               )<BR>               (if (&gt; d 0) (setq ds (rtos d 2) dt nil)<BR>                                                                                                               (setq ds "Through" dt t)<BR>                                               )<BR>               (initget 7 "Through       ")               <BR>               (setq d1 (getdist (strcat "\nOffset distance" "&lt;" ds "&gt; :")))<BR>               (if (= d1 "Through") (setq dt t)<BR>                                               (if (= d1 "") (if dt () (setq d1 d)) (setq dt nil))<BR>                                               )       <BR>               (initget 7 "       ")       <BR>               (setq e (entsel "\nSelect object to offset :"))<BR>               (while (not e)<BR>                                                                               (initget 7 "       ")<BR>                                                                               (setq e (entsel "\nSelect object to offset :"))<BR>                                                       )<BR>               (if (= e "")<BR>                                               (abcdefg)<BR>                                               (redraw (car e) 3)<BR>                               )<BR>               (setq p (getpoint "\nSide to offset?"))<BR>               (if dt (command ".offset" "T" e p "") (command ".offset" d1 e p ""))<BR>               (redraw (car e) 4)<BR>               (command "_change" (entlast) "" "p"       "La" cl "c" "Bylayer" "lt" "bylayer" "")<BR>               (setq nt t)<BR>               (while nt<BR>                                                       (initget 7 "       ")<BR>                                                       (setq e (entsel "\nSelect object to offset :"))<BR>                                                       (while (not e)<BR>                                                                               (initget 7 "       ")<BR>                                                                               (setq e (entsel "\nSelect object to offset :"))<BR>                                                                       )<BR>                                                       (if (= e "") (setq nt nil)<BR>                                                                                       (progn<BR>                                                                                                                                       (redraw (car e) 3)<BR>                                                                                                                                       (setq p (getpoint "\nSide to offset?"))<BR>                                                                                                                                       (if dt (command ".offset" "T" e p "") (command ".offset" d1 e p ""))<BR>                                                                                                                                       (command "_change" (entlast) "" "p"       "La" cl "c" "Bylayer" "lt" "bylayer" "")<BR>                                                                                                                                       (redraw (car e) 4)<BR>                                                                                                               )<BR>                                                                       )<BR>                                       )<BR>        <BR>                                                       <BR>               (reerr)<BR>               (princ)<BR>        )
页: 1 [2]
查看完整版本: [求LISP]求COPY和OFFSET新物体使之到当前层!