yu960312 发表于 2023-9-7 15:08:24

做了一个切换窗口的程序,求大神完善

本帖最后由 yu960312 于 2023-9-7 16:53 编辑

如下程序,求完善双击列表直接切换窗口功能


(defun C:sw (/ dc)
(defun mystrcat1 (i);;文本框1
(if (= fn 0)
(set_tile "edit_box1" (setq dc(cadr (nth (atoi i) myList))))
(set_tile "edit_box1" (setq dc(car(nth (atoi i) findlist))))
)
;(if (= $reason 4);;双击
;(progn
;(my_qh)
;)
;)
)

(defun my_qh();;切换按钮
(setq m 0
dwg nil
n (length myList)
dwgn 0
)
(if dc
(progn
(setq dwgn 1)
(while (< m n)
(setq str(nth m myList))
(setq str1(cadr str))
(if(wcmatch str1 dc)
(progn
(setq str2(caddr str))
(setq dwg(list str2))
(setq m (+ n 1))
)
)
(setq m (+ m 1))
)
)
)
(princ)
)

(defun my_cz();;查找按钮
(setq dcc(get_tile "edit_box1"))
(if (/= dcc "")
(progn
(setq fn 1)
(setq findlist '())
(setq findlist1 '())
(setq finds(strcat "*" dcc "*"))
(setq m 0 n (length myList))
(while (< m n)
(setq str(nth m myList))
(setq str1(cadr str))
(setq str2(caddr str))
(if(wcmatch str1 finds)
(progn
(setq findlist(append findlist (list (list str1 str2))))
)
)
(setq m (+ m 1))
)
)
)

(if (> (length findlist) 0)
(progn
(start_list "mylist" 3)
(foreach x findlist
(add_list (car x))
)
(end_list)
(alert "\n查找完成 ! ! !")
)
(alert "\n未找到 ! ! !")
)

(princ)
)

(defun my_sx();;刷新按钮
(setq i 0)
(setq fn 0)
(start_list "mylist" 3)
(foreach x myList
(add_list (cadr x))
)
(end_list)
(alert "\n刷新成功 ! ! !")
)

(setq acdocs (vla-get-Documents (vlax-get-acad-object)))
(setq i 0)
(setq fn 0)
(setq myList '())
;;myList(不带路径列表 带路径列表 object列表)
(vlax-for item acdocs
;(vlax-dump-object item)
(setq i(+ i 1))
(setq name1 (vlax-get-property item 'Name))
(setq name2 (vlax-get-property item 'WindowTitle))
(setq myList(append myList (list (list name1 name2 item))));;带路径列表&object列表
)

(setq dcl_id (load_dialog "DCL.dcl"))
(new_dialog "DCL_4" dcl_id)
(action_tile "mylist" "(setq list1_value $value)(mystrcat1 list1_value)")
(action_tile "button1" "(done_dialog 2)(my_qh)")
(action_tile "button2" "(my_cz)")
(action_tile "button3" "(my_sx)")

(setq m 0 n (length myList))
(while (< m n)
(setq str(nth m myList))
(setq str1(car str))
(if(wcmatch str1 (getvar "dwgname"))
(progn
(setq str2(cadr str))
(set_tile "edit_box1" str2)
(setq m (+ n 1))
)
)
(setq m (+ m 1))
)

(start_list "mylist" 3)
(foreach x myList
(add_list (cadr x))
)
(end_list)
(setq code(start_dialog))
(unload_dialog dcl_id)

(cond
((= code 2)
(progn
(if (= dwgn 1)
(progn
(vl-catch-all-apply 'vla-Activate dwg)
)
(progn
(princ (strcat "\n错误: 请选择切换窗口文件的路径 ! ! !"))
(alert (strcat "\n错误: 请选择切换窗口文件的路径 ! ! !"))
)
)
)
)
)
(princ)
)



yu960312 发表于 2023-9-8 15:04:27

guankuiwu 发表于 2023-9-8 09:25
(action_tile "mylist" "(setq list1_value $value)(mystrcat1 list1_value)(if (= $reason 4)(done_dialog ...

等下试试看,感谢大佬

yu960312 发表于 2023-9-8 18:41:14

guankuiwu 发表于 2023-9-8 09:25
(action_tile "mylist" "(setq list1_value $value)(mystrcat1 list1_value)(if (= $reason 4)(done_dialog ...

完美解决,感谢

yu960312 发表于 2023-9-7 18:19:13

Bao_lai 发表于 2023-9-7 18:16
虽然cad自带有图纸标签功能,你这个用不上,但还是为你钻研的精神点赞。

平时打开图档太多,找图比较麻烦,才搞了个这个程序

664571221 发表于 2023-9-7 16:39:46

兄弟你也太厉害了。

Bao_lai 发表于 2023-9-7 18:16:16

虽然cad自带有图纸标签功能,你这个用不上,但还是为你钻研的精神点赞。

664571221 发表于 2023-9-7 20:24:34

yu960312 发表于 2023-9-7 18:19
平时打开图档太多,找图比较麻烦,才搞了个这个程序

你的技术让人眼前一亮

mashanjie 发表于 2023-9-7 21:05:05

这个是需要DCL支持吗?还是可以直接在CAD加载LSP?

magicheno 发表于 2023-9-7 23:49:01

感谢大佬分享

panliang9 发表于 2023-9-8 08:43:36

谢谢楼主分享

acoff 发表于 2023-9-8 08:55:32

看着不错,多谢分享

nyistjz 发表于 2023-9-8 08:56:10

出现这个弹窗,无法正常使用。
页: [1] 2
查看完整版本: 做了一个切换窗口的程序,求大神完善