马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 Lisphk 于 2018-5-24 19:05 编辑
[JavaScript] 纯文本查看 复制代码
(defun c:c2lay ( / inc lay lst obj sel )
(if (setq sel (ssget "_:L"))
(progn
(while (setq lay (tblnext "layer" (not lay)))
(if (zerop (logand 52 (cdr (assoc 70 lay))))
(setq lst (cons (cdr (assoc 2 lay)) lst))
)
)
(if (setq lst (LM:listbox "Select Layers to Copy to" (acad_strlsort lst) t))
(repeat (setq inc (sslength sel))
(setq obj (vlax-ename->vla-object (ssname sel (setq inc (1- inc)))))
(foreach lay lst
(vla-put-layer (vla-copy obj) lay)
)
)
(princ "\n*Cancel*")
)
)
)
(princ)
)
(defun LM:listbox ( msg lst bit / dch des tmp rtn )
(cond
( (not
(and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line
(strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select="
(if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}"
)
des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "listbox" dch)
)
)
(prompt "\nError Loading List Box Dialog.")
)
( t
(start_list "list")
(foreach itm lst (add_list itm))
(end_list)
(setq rtn (set_tile "list" "0"))
(action_tile "list" "(setq rtn $value)")
(setq rtn
(if (= 1 (start_dialog))
(if (= 2 (logand 2 bit))
(read (strcat "(" rtn ")"))
(mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
)
)
)
)
)
(if (< 0 dch)
(unload_dialog dch)
)
(if (and tmp (setq tmp (findfile tmp)))
(vl-file-delete tmp)
)
rtn
)
(vl-load-com) (princ)
另外一个:
- (defun c:tt (/ *error* showdcl on lst ss i sn vl)
- ;;;--- Tharwat 25. May. 2013 ---;;;
- (or doc
- (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
- )
- (defun *error* (x)
- (if doc
- (vla-endundomark doc)
- )
- (if f
- (progn (close f) (vl-file-delete fn))
- )
- (princ "\n*Cancel*")
- )
- (defun ShowDcl (/ sn f str dcl_id l lays pos)
- (setq fn (vl-filename-mktemp "dcl.dcl"))
- (setq f (open fn "w"))
- (foreach str
- (list
- "Layers : dialog { label = \"Layer List\"; fixed_width = true;"
- ": list_box { label = \"Select Layer\"; key = \"layer\"; width = 32; multiple_select = true;}"
- ": boxed_row { label = \"Action\";" ": row {"
- ": button { label = \"Accept\"; key = \"accept\"; is_default = true; }"
- ": button { label = \"Cancel\"; key = \"cancel\"; is_cancel = true; }}}}")
- (write-line str f)
- )
- (close f)
- (setq dcl_id (load_dialog fn))
- (if (not (new_dialog "Layers" dcl_id))
- (exit)
- )
- (while (setq l (tblnext "LAYER" (not l)))
- (setq lays (cons (cdr (assoc 2 l)) lays))
- )
- (setq lays (reverse lays))
- (start_list "layer")
- (mapcar 'add_list lays)
- (end_list)
- (action_tile
- "accept"
- "(setq pos (get_tile \"layer\"))(done_dialog)"
- )
- (action_tile "cancel" "(done_dialog)")
- (start_dialog)
- (unload_dialog dcl_id)
- (if pos
- (foreach n (read (strcat "(" pos ")"))
- (setq lst (cons (nth n lays) lst))
- )
- )
- )
- (if (and (progn (princ "\n Select Polyline ...")
- (setq ss (ssget "_:L" '((0 . "*POLYLINE"))))
- )
- (setq on (ShowDcl))
- )
- (progn
- (vl-file-delete fn)
- (vla-StartUndomark doc)
- (repeat (setq i (sslength ss))
- (setq sn (ssname ss (setq i (1- i))))
- (foreach x lst
- (vla-copy (setq vl (vlax-ename->vla-object sn)))
- (vla-put-layer vl x)
- )
- )
- (vla-endundomark doc)
- )
- )
- (princ "\n Written By Tharwat Al Shoufi")
- (princ)
- )
|