乐筑天下

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

[编程交流] .Net文档。C​loseAndDis公司​汽车

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 22:06:30 | 显示全部楼层 |阅读模式
这是在Map 3D 2013中工作的。。。
 
 
 
基本上,我想做的是:
[列表=1]
  • 打开dxf文件
  • 将其数据库复制到新的dwg文件
  • 关闭dxf
    我对代码进行了一点修改,试图使其与Map 2014兼容,但没有成功。
    这是我现在的代码:
     
    1. // Open dxf
    2. DocumentDocument doc = AcadUtil.DocumentManager.Open(dxfFileName, false);
    3. // Lock Document so nothing interferes
    4. using (DocumentLock docLock = doc.LockDocument())
    5. {
    6. [indent]// Save drawing as DWG file
    7. using (Transaction tr = doc.Database.TransactionManager.StartTransaction()​)
    8. {        
    9. [/indent]
    10. [indent][indent]doc.Database.SaveAs(fileName + ".dwg", DwgVersion.Newest);
    11. tr.Commit();   
    12. [/indent]
    13. }
    14. [/indent]}
    15. // Set document active so we can close it  
    16. if (Application.DocumentManager.MdiActiveDocument != doc)
    17. {        
    18. [indent]Application.DocumentManager.MdiActiveDocument = doc;   
    19. [/indent]
    20. }
    21. // Dispose db
    22. doc.Database.Dispose();   
    23. // Close document
    24. doc.CloseAndDiscard();

     
    代码在文档上引发错误。CloseAndDiscard();
    检测到FatalExecutionEngineError。。。
     
     
    我尝试了很多不同的事情,现在我不知道该怎么做才能让这一切奏效。
    我读过关于系统变量FIBERWORLD。。。设置为1。
     
    我做错了什么??
     
    谢谢你的帮助。
  • 回复

    使用道具 举报

    4

    主题

    2143

    帖子

    2197

    银币

    限制会员

    铜币
    -24
    发表于 2022-7-6 22:23:37 | 显示全部楼层
    我把你的线移到了。NET、ObjectARX和VBA论坛。
    回复

    使用道具 举报

    44

    主题

    3166

    帖子

    2803

    银币

    中流砥柱

    Rank: 25

    铜币
    557
    发表于 2022-7-6 22:32:58 | 显示全部楼层
     
    你还没有发布完整的代码,所以很难确定。
     
    有什么特别的原因不使用ReadDwgFile()方法将DXF作为边数据库打开,而不是在编辑器中打开?
     
    快速示例:
     
    1. using Autodesk.AutoCAD.ApplicationServices;
    2. using Autodesk.AutoCAD.DatabaseServices;
    3. using Autodesk.AutoCAD.EditorInput;
    4. using System.IO;
    5. namespace FOO
    6. {
    7.    public class BAR
    8.    {
    9.        void BAZ(string filePath)
    10.        {
    11.            if (!File.Exists(filePath))
    12.                return;
    13.            Document acDoc = Application.DocumentManager.MdiActiveDocument;
    14.            Editor ed = acDoc.Editor;
    15.            using (Database db = new Database(false, true))
    16.            {
    17.                try
    18.                {
    19.                    db.ReadDwgFile(filePath, System.IO.FileShare.Read, false, "");
    20.                }
    21.                catch (System.Exception)
    22.                {
    23.                    ed.WriteMessage(
    24.                      "\nUnable to read drawing file."
    25.                    );
    26.                    return;
    27.                }
    28.                using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())
    29.                {
    30.                    BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
    31.                    BlockTableRecord btr =
    32.                        (BlockTableRecord)tr.GetObject(bt[blockTableRecord.ModelSpace], OpenMode.ForRead);
    33.                    foreach (ObjectId id in btr)
    34.                    {
    35.                        [color="red"]//<-- do something useful here[/color]
    36.                    }
    37.                }
    38.            }
    39.        }
    40.    }
    41. }

     
    谢谢你的帮助!!
    回复

    使用道具 举报

    44

    主题

    3166

    帖子

    2803

    银币

    中流砥柱

    Rank: 25

    铜币
    557
    发表于 2022-7-6 22:41:36 | 显示全部楼层
    在调试环境外运行我的代码,只需在Map 3D 2014中导入我的dll即可!!!
    调试中的某些内容一定会以某种方式损坏堆栈。。。
     
    运行我的代码进一步揭示了我的另一个问题。我在配置文件中声明了FDO提供程序(OSGeo.SQLServerSpatial)版本。
    Map 3D 2013使用3.7,Map 3D 2014使用3.8。
    我甚至意识到你根本不需要声明FDO提供商的版本,它仍然有效!
     
    谢谢你的帮助,非常感谢!
    回复

    使用道具 举报

    1

    主题

    3

    帖子

    2

    银币

    初来乍到

    Rank: 1

    铜币
    5
    发表于 2022-7-6 22:55:52 | 显示全部楼层
    垂直(例如Civil 3D)就像洋葱。。。Civil 3D构建在Map 3D之上,Map 3D本身构建在AutoCAD之上。。。为了执行给定的任务,您只需要访问适当的“洋葱”层(在本例中是AutoCAD,而不是Map)。
     
    如果您正在通过网络加载程序集(一个插件,而不是独立的应用程序),那么当您可以使用应用程序时,甚至不需要使用AcadUtil(COM对象,这也使您的代码与环境相关,即x86或x64)。本机的DocumentManager对象。NET API并编译到任何CPU。。。我忘记了哪个框架实现了动态(4.0?),但这是另一种排除环境依赖性(早期/晚期绑定)的方法,同时利用COM(如果这是您真正想要的途径)。
     
    此外,您可能会发现自动加载机制很有用,这里有一个最新的线程可能会有所帮助。
     
    干杯
    回复

    使用道具 举报

    1

    主题

    3

    帖子

    2

    银币

    初来乍到

    Rank: 1

    铜币
    5
    发表于 2022-7-6 22:59:13 | 显示全部楼层
    回复

    使用道具 举报

    44

    主题

    3166

    帖子

    2803

    银币

    中流砥柱

    Rank: 25

    铜币
    557
    发表于 2022-7-6 23:10:21 | 显示全部楼层
    Verticals (for example, Civil 3D) are like an onion... Civil 3D is built on top of Map 3D, which is itself built on top of AutoCAD... You need only access the appropriate 'onion' layer (in this instance AutoCAD, not Map) in order to perform a given task.
     
    If you're NETLOADing your assembly (a plug-in, not stand alone app), then there's no need to even use AcadUtil (COM Object, which also makes your code environment dependent, i.e., x86 or x64), when you can use the Application.DocumentManager Object which is native to .NET API and compile to AnyCPU... I forget which framework implements dynamics (4.0?), but that is yet another way of precluding environment dependency (early/late binding), whilst utilizing COM (if that's the route you really want to take).
     
    Also, you may find the Autoloader Mechanism to be of use, here's a recent thread that may help.
     
    Cheers
    回复

    使用道具 举报

    发表回复

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

    本版积分规则

    • 微信公众平台

    • 扫描访问手机版

    • 点击图片下载手机App

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

    GMT+8, 2025-3-4 11:25 , Processed in 1.126533 second(s), 66 queries .

    © 2020-2025 乐筑天下

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