明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2295|回复: 5

[求助]如何保存缩略图?

[复制链接]
发表于 2009-10-13 10:37 | 显示全部楼层 |阅读模式

打开后关闭并保存

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(operFilePath, false);

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                Database db = doc.Database;
                Editor ed = doc.Editor;

savepath = operFilePath;
                doc.CloseAndSave(savepath);

之后,发现如果原来图形有缩略图的,保存之后还会有缩略图,原来没有缩略图的,保存之后还是没有。但是原来没有缩略图的,我手工打开DWG,然后保存一下就有缩略图了。

请问如何把缩略图保存出来?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2009-10-13 19:23 | 显示全部楼层
命令 : BLOCKICON
 楼主| 发表于 2009-10-13 20:03 | 显示全部楼层

没用啊

for (iDwg = 0; iDwg < dwgCount; iDwg++)
            {
                operFilePath = dwgFilesRoute[iDwg].ToString();//获得操作图形路径
                if (fileType=="DWG")
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(operFilePath, false);
                }
                else//DXF
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(operFilePath, true);
                }
               

                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                Database db = doc.Database;
                Editor ed = doc.Editor;

                //db.CloseInput(true);
                //DocumentLock lok = doc.LockDocument();

                //Utils.ZoomObjects(true);//范围缩放视图
                //curVtr = ed.GetCurrentView();
                //Point2d d2d = new Point2d(curVtr.Target.X, curVtr.Target.Y);
                //curVtr.CenterPoint = new Point2d(0, 0);
                //curVtr.Target = new Point3d(0, 0, 0);
                //curVtr.ViewDirection = new Vector3d(0, 0, 1);
                //curVtr.CenterPoint = d2d;

                //ed.SetCurrentView(curVtr);

                //lok.Dispose();
                doc.SendStringToExecute("BLOCKICON",true,false,false);


                //db.Save();
                labelExecuteCondition.Text = "正在范围缩放" + System.IO.Path.GetFileName(operFilePath) + "视图,请等待……";
                labelExecuteCondition.Visible = true;
                finish = (int)((Double)(iDwg + 1) / (Double)(dwgCount) * 100);
                progressBar1.Value = finish;
                progressBar1.Visible = true;
                this.Update();
                //savepath = System.IO.Path.GetDirectoryName(operFilePath) + System.IO.Path.GetFileNameWithoutExtension(operFilePath);
                //savepath = folderPath+System.IO.Path.GetFileNameWithoutExtension(operFilePath);
                //savepath = "D:\\杂记\\1";
                savepath = operFilePath;
                doc.CloseAndSave(savepath);

                //try
                //{
                //    doc.CloseAndSave(savepath);
                //}
                //catch (System.Exception eRR)
                //{
                //    doc.CloseAndSave(temppath);
                //    if (fso.FileExists(operFilePath))
                //    {
                //        fso.DeleteFile(operFilePath, true);
                //    }

                //    fso.MoveFile(temppath, operFilePath);
                //}

                //if(fileType=="DWG")
                //{
                //    doc.CloseAndSave(savepath);
                //}

                //if (fileType == "DXF")
                //{
                //    doc.CloseAndSave(temppath);
                //    if (fso.FileExists(operFilePath))
                //    {
                //        fso.DeleteFile(operFilePath, true);
                //    }

                //    fso.MoveFile(temppath, operFilePath);
                //}

            }

发表于 2009-10-14 19:14 | 显示全部楼层

汗,搞错,blockicon是生成块图标的:)

不过缩略图为什么需要?

可以试下Wblock或直接调用Save命令

 楼主| 发表于 2009-10-14 23:06 | 显示全部楼层

算了,缩略图不要也罢

只是有个问题,就是比如点击一个按钮,但是按钮执行的是一个循环,循环体如果使用editor发送命令,无论什么命令,都不执行。

还有,如果不是循环,那么发送的命令会在这个按钮事件函数全部执行完毕之后,CAD开始执行发送的命令。不知道这是为什么。

[CommandMethod("MODFRM",CommandFlags.Session)]
        public void modify()
        {
           
           
            DwgFrame Fra = new DwgFrame();
            Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(Fra);
        }

DwgFrame 是一个窗体,上面有按钮。不知道怎样才能让按钮事件中发送的命令立即执行,执行之后再回到按钮事件继续往下执行?

发表于 2009-10-15 09:05 | 显示全部楼层

SendStringToExecute会产生延时,试下这个

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=78074

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-21 02:20 , Processed in 0.275369 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表