乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: dbroada

[编程交流] 在VB中保存图形。网

[复制链接]

48

主题

1073

帖子

1043

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
238
发表于 2022-7-6 23:07:50 | 显示全部楼层
我以前遇到过他——甚至都不去搜索是否有人问过这个问题!
 
请注意,我不知道他试过VB。那时候的网。可能试过一次,但不喜欢。
 
我将尝试下一步执行Send字符串(可能是明天)。
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 23:09:41 | 显示全部楼层
*寻找我的“简易按钮”*
 
  1. using Autodesk.AutoCAD.ApplicationServices;
  2. using Autodesk.AutoCAD.Runtime;
  3. using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
  4. [assembly: CommandClass(typeof(CADTutor.Sample.OpenDocInSdiMode.Commands))]
  5. namespace CADTutor.Sample.OpenDocInSdiMode
  6. {
  7.    public class Commands
  8.    {
  9.        [CommandMethod("FOO")]
  10.        public void FOO()
  11.        {
  12.            Document doc = acApp.DocumentManager.MdiActiveDocument;
  13.            // if document has not been titled,
  14.            if (System.Convert.ToInt16(acApp.GetSystemVariable("DWGTITLED")) != 1
  15.                // or has unsaved changes
  16.                | System.Convert.ToInt16(acApp.GetSystemVariable("DBMOD")) != 0)
  17.                // save the document
  18.                doc.SendStringToExecute("._QSAVE\n", false, false, true);
  19.            // then prompt to open another document
  20.            doc.SendStringToExecute("._OPEN\n", false, false, true);
  21.        }
  22.    }
  23. }

 
**注意-我将SendStringToExecute()方法的echoCommand参数保留为true,因为当显示仅表示“选择文件”的“打开”对话框时,我发现它可能会令人困惑考虑到要打开的文档的文件名是已知的,您可能希望将其更改为false,因此在命令行中不会回显任何内容。
 
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
238
发表于 2022-7-6 23:14:27 | 显示全部楼层
然后要做更多的阅读
 
在你的帖子出现之前,我已经尝试了一些事情,这似乎是一条可行的道路。
 
我不必添加“保存?”开放式对话为我提供舞台。如果绘图已更改,系统会询问您是否要保存它,因为保存并不总是需要的,这对我来说很有效。
 
我看不到的是如何构建字符串,因为我知道我想要的文件名。如果我使用“打开”&文件名;我打开了对话框。到目前为止,我最好的解决方法是在启动命令之前将FILEDIA设置为0(仍在AutoCAD atm中)。不过我希望我不需要做那么长时间。
 
我还没有用“\u OPEN”试过。
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 23:20:37 | 显示全部楼层
实际上,DocumentManager。Open()工作正常。。。即使在SDI=1的情况下。
 
  1. using Autodesk.AutoCAD.Runtime;
  2. using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
  3. [assembly: CommandClass(typeof(CADTutor.Sample.OpenDocInSdiMode.Commands))]
  4. namespace CADTutor.Sample.OpenDocInSdiMode
  5. {
  6.    public class Commands
  7.    {
  8.        [CommandMethod("CADTutor", "FOO", [color="red"]CommandFlags.Session[/color])]
  9.        public void FOO()
  10.        {
  11.            string dwg = "[color="blue"]YourFilePath[/color]\\[color="blue"]YourFileName[/color].dwg";
  12.            acApp.DocumentManager.Open(dwg);
  13.        }
  14.    }
  15. }

 
... 关键是CommandFlags。会话属性,这是我在这篇文章中从Tony那里学到的,在谷歌上搜索了一下这个主题。
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
238
发表于 2022-7-6 23:24:53 | 显示全部楼层
太棒了!!!
 
 
昨天我很早就去参加Melody Gardot的演唱会,错过了这个节目(也很棒,因为我们下周要去巴黎见她)。
 
我现在已经看到了,而且它很有效。只要多一点逻辑就行了,我就在那里。我可以使用。如果文件存在,则打开方法。SendStringToexecute(“打开”),如果没有。
 
再次感谢您。(看来我不需要读太多,因为BB为我做了这么好的工作)。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-5-25 16:39 , Processed in 0.410953 second(s), 71 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表