;| 获得所有图层 参数:无 返回值:表 |; ; user defined function strsplit. ; strsplit splits a string with delimiter, and return a list. ; example: (strsplit "1,22,333,4444" ",") -->> ("1","22","333","4444") ; (strsplit ",1,22,333,4444," ",") -->> ("" "1" "22" "333" "4444" "") (defun strsplit(datastr delimiter) (setq strlist '() str "" ) (setq n (strlen datastr)) (setq i 1) (repeat n ; s is a single letter, starts from the first to the end. (setq s (substr datastr i 1)) (if (/= s delimiter) ; when s is't a delimiter (progn (setq str (strcat str s)) ; if s is the last letter (if (= i n) (setq strlist (cons str strlist)) ) ) ; when s is a delimiter (progn (setq strlist (cons str strlist)) (setq str "") ; if delimiter is the last letter (if (= i n) (setq strlist (cons "" strlist)) ) ) ) (setq i (1+ i)) ) ; reverse list and retrun it (reverse strlist) ) (defun XD::Layer:GetAll ( / e layerl obj) (setq obj (xdrx_object_get "layer")) (while (setq e (xdrx_object_next)) (setq layerl (cons (car e) layerl)) ) (setq layerl (reverse layerl)) ) (defun main( / name lys addlys first others klens n) (setq name (getstring "要合并图层名称,多个用逗号隔开:")) (if (/= name "") (progn (setq keys (strsplit name ",")) (setq lys (XD::Layer:GetAll)) (setq addlys (list)) (setq klens (length keys)) (foreach e lys (setq n 0) (while (< n klens) (setq key (nth n keys)) (if (vl-string-search key e) (progn (setq addlys (append addlys (list e))) (setq n klens) ) (setq n (+ n 1)) ) ) ) (setq first (car addlys)) (setq others (cdr addlys)) (princ addlys) (foreach k others (command "laymrg" "N" k "" "N" first "Y") ) ) (princ "input is nil") ) ) (defun c:mrly() (main) )
合并CAD图层,
图层关键字,多个关键字,必需晓东工具箱
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/211636.html原文链接:https://javaforall.net
