澷歩澐鍴 发表于 2012-5-26 16:08:44

为什么不能在对话框image上显示图形?

(defun c:dwgpre()
      (vl-load-com)
      (setq dwgfiles '(" "))
      (show_dlg)
);end defun c:dwgpre
(defun show_dlg()
      (if (null (setq dcl_id (load_dialog "d:\\shit\\image_dcl")))
   (progn
(alert "failed in loading dialog")
(exit)
   );end progn
      );end if-load dialog
      (new_dialog "img_pre" dcl_id)
      (action_tile "path_sel" "(getf_dwg) (showlist \"dwg_list\")");选择文件夹
      (action_tile "dwg_list" "(getl_data $value)");获取列表框选择数据
      (action_tile "image_pre" "(setq slnm \"dwg_preview \")")
      (action_tile "btn_pre" "(done_dialog 1)");预览
      (action_tile "btn_exit" "(done_dialog 2)");退出
      (setq zhqtask (start_dialog))
      (cond
   ((= zhqtask 1)(dwg_preview));用户操作
   ((= zhqtask 2)(tmp_del))
   (t (princ));
      );end if
);end defun show_dialog
(defun getfolder(/ WinShell shFolder catchit)
(setq winshell (vlax-create-object "Shell.Application"))
(setq    shFolder (vlax-invoke-method WinShell 'BrowseForFolder 0 "选择文件夹" 1))
(setq    catchit (vl-catch-all-apply'(lambda ()
                (setq shFolder (vlax-get-property shFolder 'self))
                (setq path (vlax-get-property shFolder 'path))
             )
   )
)
(if (vl-catch-all-error-p catchit)      nil      path)
);end defun
(defun getf_dwg()
      (if (getfolder)
   (setq dwgfiles (vl-directory-files path "*.dwg" 1))
   (progn
(alert "没有选择文件夹")
(exit)
   )
      );end if
);end defun get_dwg
(defun showlist(lkey);列表填充函数
      (start_list lkey)
      (mapcar 'add_list dwgfiles)
      (end_list)
);end showlist
(defun getl_data(str);get list_box data
      (setq dwgpath (strcat path "/" (nth (atoi str) dwgfiles)))
);end dwg_pre
(defun dwg_preview()
      (princ dwgpath);
);end defun dwg_preview
(command "mslide" dwg_preview)
(defun show_sld (/ sldnm width heigth)
   (start_image "image_pre");开始处理图像对象
          (setq width (dimx_tile "image_pre"))
   (setq height (dimy_tile "image_pre"))
          (fill_image 0 0 width heigth -3);填充
   (slide_image 0 0 width heigth sldnm);展示幻灯片
   (end_image);结束处理图像对象
   )
(defun tmp_del();退出时删除临时文件
      (princ "delete sld files and then exit")
)



http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 澷歩澐鍴的微博

ZZXXQQ 发表于 2012-5-26 22:50:27

本帖最后由 ZZXXQQ 于 2012-5-26 22:52 编辑

这行是干什么的?
(command "mslide" dwg_preview)

xgr 发表于 2012-5-27 01:34:15

楼主是想实现生成幻灯片,供对话框预览,
请确定(command "mslide" dwg_preview)是否是在对话框加载之前生成,
程序太乱,又缺少对话框文件,不能测试。

澷歩澐鍴 发表于 2012-5-27 08:08:17

ZZXXQQ 发表于 2012-5-26 22:50 static/image/common/back.gif
这行是干什么的?
(command "mslide" dwg_preview)

我想把dwg文件转化为幻灯片格式,再在对话框上预览

澷歩澐鍴 发表于 2012-5-27 08:11:01

xgr 发表于 2012-5-27 01:34 static/image/common/back.gif
楼主是想实现生成幻灯片,供对话框预览,
请确定(command "mslide" dwg_preview)是否是在对话框加载之前生 ...

img_pre:dialog
{
        label="图形预览对话框";
        :row
        {
                :boxed_column
                {
                        :image{key="image_pre";width=100;}
                }
                :boxed_column
                {
                        :button{label="选择文件夹";key="path_sel";}
                        :list_box{label="图形文件名称";key="dwg_list";fixed_width_font=true;}
                        :row
                        {
                                :button{label="预览";key="btn_pre";}
                                :button{label="退出";key="btn_exit";}
                                cancel_button;
                        }
                }
        }
       
}


这是对话框文件,请多多指教!

xgr 发表于 2012-5-27 08:44:38

用DosLib吧,很简单就能做到。
dos_dwgpreview显示图形文件的列表及它们的缩略预览图的对话框. 这个函数在选择打开图形和插入块时很有用.
语法 (dos_dwgpreview title path [T]) (dos_dwgpreview title path-list [T]) 参数 title 对话框标题.

path 指定路径. 如果指定nil则使用当前路径.

path-list包含图形文件完整路径的列表.

T 在黑与白之间切换预览图的默认背景色.
返回 选择文件的完整路径.
nil 取消或出错时.
示例 Command: (dos_dwgpreview "Preview a drawing" "c:\\program files\\autocad 2002\\sample") "c:\\program files\\autocad 2002\\sample\\1st floor architectural.dwg" 根据CAD的版本可以选择DosLib的版本。

澷歩澐鍴 发表于 2012-5-28 16:37:11

xgr 发表于 2012-5-27 08:44 static/image/common/back.gif
用DosLib吧,很简单就能做到。
dos_dwgpreview显示图形文件的列表及它们的缩略预览图的对话框. 这个函数在 ...

能用autolisp程序做到吗?

xgr 发表于 2012-5-28 21:01:23

(command "mslide" dwg_preview)
这只能生成当前打开的DWG文件的幻灯片啊。

澷歩澐鍴 发表于 2012-5-29 05:59:41

xgr 发表于 2012-5-28 21:01 static/image/common/back.gif
(command "mslide" dwg_preview)
这只能生成当前打开的DWG文件的幻灯片啊。

但是驱动对话框后只能将当前文件制作成幻灯片,而不能在对话框上显示出来,这是为什么?

xgr 发表于 2012-5-29 07:59:50

(defun c:slide_show (/ dcl_id q1)
(vl-load-com)
(command "mslide" "c:\\slide_image")
(setq dcl_id (load_dialog "ABCD.dcl"))
(setq q1 (new_dialog "slide_show" dcl_id))
(start_image "s1")
(fill_image 0 0 (dimx_tile "s1") (dimy_tile "s1") 0)
(slide_image 0 0 (dimx_tile "s1") (dimy_tile "s1") "c:\\slide_image.sld")
(end_image)
(action_tile "cancel" "(done_dialog)(exit)")
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete "c:\\slide_image.sld")
)
显示当前文件为幻灯片
DCL文件
slide_show:dialog {
    label = "幻灯片显示";
    :image {
      width = 100;
      height = 30;
      key = "s1";
      }
    ok_cancel ;
    }



页: [1]
查看完整版本: 为什么不能在对话框image上显示图形?