zhaohaijun
发表于 2011-1-6 12:07:46
真是好东西
redcat
发表于 2011-1-7 16:07:14
本帖最后由 redcat 于 2011-3-7 15:24 编辑
在老迈的基础上修改了一下:主要是文件生成和删除2个函数(请麦工不要生气,呵呵^_^);;用户可自己修改界面
(defun c:xxx ()
(mai_make_panel
(list
(list "梁"
(list "画 梁" "circle") ;(list按钮标签运行的命令)
(list "单线变梁" "mini_line_to_beam")
(list "筏板梁倒角" "mini_foundation_beam")
(list "修补梁柱" "mini_fix_beam")
(list "修补双线" "mini_fix_dline")
(list "框选修补线" "mini_fix_line")
) ;_ 结束list
(list "柱"
(list " + 型柱" "mini_c_column")
(list " L 型柱" "mini_l_column")
(list " T 型柱" "mini_t_column")
(list " ○ 型柱" "mini_O_column")
(list " □ 型柱" "mini_r_column")
(list "轴线布柱" "mini_axis_column")
(list "填 充 柱" "mini_fill_column")
(list "墙体填充" "mini_fill_wall")
(list "转PKPM GS柱" "mini_pline_to_beam")
(list "多线变柱" "mini_pline_to_column")
) ;_ 结束list
) ;_ 结束list
) ;_ 结束mai_make_panel
(princ)
) ;_ 结束defun
(defun mai_make_panel (menulist / m n nn nnn menuname val_lst tt order_lst)
(defun add_dclrow (dstr)
(ifdstr
(setq val_lst (cons dstr val_lst))
) ;_ 结束if
) ;_ 结束defun
(add_dclrow "curbutton : button{width=10;vertical_margin=none;vertical_margin=none;}")
(add_dclrow
"curpanel : dialog{label=\"迷你工具箱\";alignment=centered;vertical_margin=none;horizontal_margin=none;"
) ;_ 结束add_dclrow
(add_dclrow ":row{")
(setqlen (apply 'max (mapcar 'length menulist))
order_lst (apply 'append (mapcar 'cdr menulist))
n 0
m 0
) ;_ 结束setq
(foreach nn menulist
(add_dclrow
(strcat " : boxed_column{label=\"" (car nn) "\";vertical_margin=none; horizontal_margin=none;")
) ;添加列表框
(foreach nnn (cdr nn)
(setq n(1+ n)
tt (car nnn)
tt (if tt
tt
""
) ;_ 结束if
) ;_ 结束setq
(add_dclrow (strcat " : curbutton{key=\"but" (vl-princ-to-string n) "\";label=\"" tt "\";}"))
) ;添加列表框中的按钮
(repeat (- len (length nn))
(setq m (1+ m))
(add_dclrow (strcat " : curbutton{key=\"butno" (vl-princ-to-string m) "\";}"))
) ;按列补齐列表框中的按钮
(add_dclrow "}")
) ;_ 结束foreach
(add_dclrow
"}:button{label=\"关闭\";key=\"cancel\";is_cancel=true;width=10;fixed_width=true;alignment=centered;}}"
)
(setq menuname (vl-filename-mktemp "temp_pannel.dcl"))
(setq nn (open menuname "w"))
(foreach n (reverse val_lst) (write-line n nn))
(close nn)
(setq nnn (load_dialog menuname))
(vl-file-delete menuname)
(if (not (new_dialog "curpanel" nnn))
(exit)
) ;_ 结束if
(setq n 0)
(repeat m (mode_tile (strcat "butno" (vl-princ-to-string m)) 1) (setq m (1- m))) ;禁用补齐列表框中的按钮
(foreach nn menulist
(foreach nnn (cdr nn)
(setq n(1+ n)
tt (car nnn) ;tt order_lst
tt (if tt
tt
""
) ;_ 结束if
) ;_ 结束setq
(if (= tt "")
(mode_tile (strcat "but" (vl-princ-to-string n)) 1)
(action_tile
(strcat "but" (vl-princ-to-string n))
(strcat "(done_dialog " (vl-princ-to-string n) ")")
) ;_ 结束action_tile
) ;_ 结束if
) ;_ 结束foreach
) ;_ 结束foreach
(setq nn (start_dialog))
(unload_dialog nnn)
(if (> nn 0)
(progn (setq tt (cadr (nth (1- nn) order_lst))) ;取点击按钮的值(这个很关键)
(if (= (eval (read (strcat "(type c:" tt ")"))) 'SUBR)
(progn (princ "\n")
(eval (read (strcat "(c:" tt ")")))
) ;_ 结束progn
(progn
(princ "\n")
(vla-SendCommand (vla-get-ActiveDocument(vlax-get-acad-object)) (strcat tt "\n"))
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束progn
) ;_ 结束if
) ;_ 结束defun
szmaicy
发表于 2011-1-7 16:14:21
回复 redcat 的帖子
灰常好
zfsaaa
发表于 2011-1-7 16:37:55
我下了,可是不知道如何用?如何加载?望详细些,谢谢!
szmaicy
发表于 2011-1-7 16:41:59
本帖最后由 szmaicy 于 2011-1-7 16:46 编辑
回复 szmaicy 的帖子
;修改版,向飞诗学习
(defun c:xxx ()
(mai_make_panel
(list
(list "梁"
(list "画 梁" "circle") ;(list按钮标签运行的命令)
(list "单线变梁" "mini_line_to_beam")
(list "筏板梁倒角" "mini_foundation_beam")
(list "修补梁柱" "mini_fix_beam")
(list "修补双线" "mini_fix_dline")
(list "框选修补线" "mini_fix_line")
) ;_ 结束list
(list "柱"
(list " + 型柱" "mini_c_column")
(list " L 型柱" "mini_l_column")
(list " T 型柱" "mini_t_column")
(list " ○ 型柱" "mini_O_column")
(list " □ 型柱" "mini_r_column")
(list "轴线布柱" "mini_axis_column")
(list "填 充 柱" "mini_fill_column")
(list "墙体填充" "mini_fill_wall")
(list "转PKPM GS柱" "mini_pline_to_beam")
(list "多线变柱" "mini_pline_to_column")
) ;_ 结束list
) ;_ 结束list
) ;_ 结束mai_mak_panel
(princ)
)
(defun mai_make_panel ( menulist / n num_nobut num_button nn nnn menuname val_lst add_dclrow tt order_lst in num_image)
(defun add_dclrow ( dstr / ) (if dstr (setq val_lst (cons dstr val_lst))))
(setq menuname (strcat (vl-filename-mktemp) "temp_pannel.dcl"))
(add_dclrow "curbutton:button{width=10;vertical_margin=none;vertical_margin=none;}")
(add_dclrow "curimage:image{width=10;height=0.2;vertical_margin=none;vertical_margin=none;}")
(add_dclrow "curpanel:dialog{label=\"迷你自定义面板\";alignment=centered;vertical_margin=none;horizontal_margin=none;")
(add_dclrow ":row{")
(setq len (apply 'max (mapcar 'length menulist))
order_lst (apply 'append (mapcar 'cdr menulist))
num_button 0
num_nobut 0
in 0
num_image 0
)
(foreach nn menulist
(setq in 0)
(add_dclrow (strcat " : boxed_column{label=\"" (car nn) "\";vertical_margin=none; horizontal_margin=none;"))
(foreach nnn (cdr nn)
(setq num_button (1+ num_button)
in (1+ in)
num_image (1+ num_image)
tt (car nnn)
tt (if tt tt "")
)
(add_dclrow (strcat ":curbutton{label=\"" tt "\";key=\"but" (itoa num_button) "\";}"))
(if (= 4 in)
(progn (add_dclrow (strcat ":curimage{key=\"ima" (itoa num_image) "\";color=18;}"))
(setq in 0)
)
)
)
(repeat (- len (length nn))
(setq num_nobut (1+ num_nobut)
in (1+ in)
num_image (1+ num_image)
)
(add_dclrow (strcat " : curbutton{key=\"butno" (itoa num_nobut) "\";color=-2;}"))
(if (= 4 in)
(progn (add_dclrow (strcat ":curimage{key=\"ima" (itoa num_image) "\";}"))
(setq in 0)
)
)
)
(add_dclrow "spacer;}")
)
(add_dclrow "}:button{label=\"关闭\";key=\"cancel\";is_cancel=true;width=10;fixed_width=true;alignment=centered;}}")
(vl-file-delete menuname)
(setq nn (open menuname "w"))
(foreach n (reverse val_lst) (write-line n nn))
(close nn)
(setq nnn (load_dialog menuname))
(if (not (new_dialog "curpanel" nnn)) (exit))
(setq n 0)
(repeat num_nobut (mode_tile (strcat "butno" (itoa num_nobut)) 1) (setq num_nobut (1- num_nobut)))
(foreach nn menulist
(foreach nnn (cdr nn)
(setq n (1+ n)
tt (car nnn)
tt (if tt tt "") tt order_lst
)
(if (= tt "")
(mode_tile (strcat "but" (itoa n)) 1)
(action_tile (strcat "but" (itoa n)) (strcat "\(done_dialog " (itoa n) "\)"))
)
)
)
(setq nn (start_dialog))
(unload_dialog nnn)
(vl-file-delete menuname)
(if (> nn 0)
(progn (setq tt (cadr (nth (1- nn) order_lst)))
(princ "\n")
(if (= (eval (read (strcat "(type c:" tt ")"))) 'SUBR)
(eval (read (strcat "(c:" tt ")")))
(vl-cmdf tt)
)
)
)
)
xzqk132
发表于 2011-1-7 17:06:34
顶麦工,不错
hhh454
发表于 2011-1-8 14:44:13
这个很好用,和信的一样,简化迷你的,很强呀,可以自己做面板了
cdmdrd
发表于 2011-1-8 22:29:48
这个.....友情顶帖
lanlj0772
发表于 2011-1-9 08:16:43
谢谢分享!好好学习
qcw911
发表于 2011-1-10 08:55:57
本帖最后由 qcw911 于 2011-1-10 08:58 编辑
自定义的lisp也好用
(list "画 梁" "hf")
用ap添加了 hf的lisp
(defun c:hf()
..........
)
页:
1
[2]
3
4
5
6
7
8
9
10
11