((= key "List1") ; {} (普通列表)
(setq sld (nth (read value) slds))
(setq dwg (strcat default_path (vl-filename-base sld) ".dwg"))
)
改为如下一试:
((= key "List1")
(setq sld (nth (read value) slds))
(setq dwg (strcat default_path sld))
(start_image "Image1")
(fill_image 0 0 (dimx_tile "Image1") (dimy_tile "Image1") 0)
(slide_image
0
0
(dimx_tile "Image1")
(dimy_tile "Image1")
dwg
)
(end_image)
)
好像还是不行
幻灯片文件生成了没有?
还有前面这行:(setq slds (vl-directory-files default_path "*.dwg" 1))
也要改为:(setq slds (vl-directory-files default_path "*.sld" 1)) 将.dwg替换为.sld (defun c:fx1 ()
(defun show-sld()
(start_image "Image1")
(fill_image 0 0 (dimx_tile "Image1") (dimy_tile "Image1") 0)
(slide_image
0
0
(dimx_tile "Image1")
(dimy_tile "Image1")
;dwg
sld
)
(end_image)
)
(setvar "cmdecho" 0)
(vl-load-com)
;;;(setq dcl_id (load_dialog
;;; "C:\\Program Files\\AutoCAD 2010\\Support\\FX.dcl"
;;; )
;;;) ;对话框加载
(make_FX_dcl) ;;生成对话框
(setq default_path "C:\\Program Files\\AutoCAD 2010\\Support\\")
(setq slds (vl-directory-files default_path "*.sld" 1))
(setq Dialog_Return 2)
(while (> Dialog_Return 1) ;循环控制对话框是否结束
(defun Action_Form1_Keys (key value) ;全部控件的点击动作触发
(cond
((= key "accept") ;{确认按钮}
(done_dialog 1) ;对话框退出返回主函数 传递给Dialog_Return值为1
)
((= key "cancel") ;{取消按钮}
(done_dialog 0) ;对话框退出返回主函数 传递给Dialog_Return值为0
)
((= key "List1")
;(setq sld (nth (read value) slds))
;(setq dwg (strcat default_path sld))
(setq sld (strcat default_path (nth (read value) slds)))
(setq dwg (vl-string-subst ".dwg" ".sld" sld))
(show-sld)
)
)
)
(new_dialog "FX" dcl_id) ;建立窗体
;-->-->-对话框初始化->-->--
(setq
keys '("List1" "Image1" "accept" "cancel")
) ;列表全部控件名称
(start_list "List1") ;直列表 {"List1"} 初始化
(mapcar 'add_listslds) ;添加列表项
(end_list)
(set_tile "List1" "0")
(setq sld (strcat default_path (car slds)))
(show-sld)
(foreach key keys ;全部控件的初始化
(action_tile key "(Action_Form1_Keys $key $value)") ;点击动作
)
;--<--<-对话框初始化完成-<--<--
(setq Dialog_Return (start_dialog)) ;开启对话框(用户可见)
(cond
((= Dialog_Return 1)
(setq pt (getpoint "\n请选择插入点"))
(if pt
(command "Insert" dwg Pt "1" "1" PAUSE)
)
)
)
(unload_dialog dcl_id) ;退出时卸载对话框
(princ) ;防止函数回显
)
(setvar "cmdecho" 1)
(princ)
)
; ;; 采用临时文件生成DCL对话框
(defun make_FX_dcl()
(setq dclfile (vl-filename-mktemp nil nil ".dcl")
fff (open dclfile "w")
)
(foreach str
(list
"FX:dialog {"
" label = \" 标准紧固件\" ;"
" :spacer {}"
" :row {"
" :boxed_column {"
" label = \"图像预览\" ;"
" :image {"
" alignment = centered ;"
" color = black ;"
" fixed_height = true ;"
" height = 12 ;"
" key = \"Image1\" ;"
" width = 25 ;"
" }"
" }"
" :boxed_column {"
" label = \"单选列表\" ;"
" :list_box {"
" fixed_height = true ;"
" height = 13 ;"
" key = \"List1\" ;"
" width = 30 ;"
" }"
" :spacer {}"
" }"
" }"
" :spacer {}"
" :image {"
" color = red ;"
" height = 0.2 ;"
" }"
" :spacer {}"
" :row {"
" alignment = centered ;"
" :text {"
" label = \"\" ;"
" }"
" ok_cancel;"
" }"
"}"
)
(write-line str fff)
)
(close fff)
(setq dcl_id (load_dialog dclfile))
(vl-file-delete dclfile)
)
页:
[1]