使用 Civil 3D Design Automation 将 landxml 文件转换为 dwg,以便在 Forge Viewer 中显示

发布于 2025-01-16 09:51:03 字数 1647 浏览 2 评论 0原文

我想在 forge 查看器上显示 landxml 文件,但由于 Model Derivative API 不支持将 landxml 转换为 svf,我决定使用 Design Automation 将 landxml 文件转换为 svf 可转换文件(dwg)。

而且因为Civil 3D支持将landxml导入到dwg文件中,所以我想使用这个功能并参考下面的文章在Civil 3D上使用Design Automation。 https://forge.autodesk.com/blog/design- Automation-civil-3d-public-beta

该命令的代码如下所示,

[CommandMethod("UsingLandXMLIn")]
    public static void UsingLandXMLIn(string filelocation)
    {
        Database db = Application.DocumentManager.MdiActiveDocument.Database;
        using (Transaction trans = db.TransactionManager.StartTransaction())
        {
            try
            {
                string currentDirectory = Path.GetDirectoryName(db.OriginalFileName);
                var edf = Application.DocumentManager.MdiActiveDocument.Editor;
                var sFileName = Path.Combine(currentDirectory, "test.xml");
                edf.Command("-landxmlin", sFileName);
                edf.Command(".ZOOM", "E");
                db.SaveAs(Path.Combine(currentDirectory, "out.dwg"), DwgVersion.Newest);
            }
            catch (Exception e)
            {
                string currentDirectory = Path.GetDirectoryName(db.OriginalFileName);
                File.WriteAllText(Path.Combine(currentDirectory, "error.txt"), e.Message + "\n" + e.StackTrace + "\n" + Path.Combine(currentDirectory, "test.xml"));
            }
            trans.Commit();
        }

    }

当我执行它时,landxmlin 命令似乎失败并返回 eInvalidInput 异常。

所以我想问是否有其他方法可以显示landxml(具有完整属性),或者如何修复上面的代码。

I want to display the landxml file on forge viewer, but since Model Derivative API doesn't support converting landxml to svf, I decided to use Design Automation to convert landxml file to svf convertable file (dwg).

And because Civil 3D supports importing landxml into dwg files, I want to use this feature and referred to the article below to use Design Automation on Civil 3D.
https://forge.autodesk.com/blog/design-automation-civil-3d-public-beta

The code for the command looks like below,

[CommandMethod("UsingLandXMLIn")]
    public static void UsingLandXMLIn(string filelocation)
    {
        Database db = Application.DocumentManager.MdiActiveDocument.Database;
        using (Transaction trans = db.TransactionManager.StartTransaction())
        {
            try
            {
                string currentDirectory = Path.GetDirectoryName(db.OriginalFileName);
                var edf = Application.DocumentManager.MdiActiveDocument.Editor;
                var sFileName = Path.Combine(currentDirectory, "test.xml");
                edf.Command("-landxmlin", sFileName);
                edf.Command(".ZOOM", "E");
                db.SaveAs(Path.Combine(currentDirectory, "out.dwg"), DwgVersion.Newest);
            }
            catch (Exception e)
            {
                string currentDirectory = Path.GetDirectoryName(db.OriginalFileName);
                File.WriteAllText(Path.Combine(currentDirectory, "error.txt"), e.Message + "\n" + e.StackTrace + "\n" + Path.Combine(currentDirectory, "test.xml"));
            }
            trans.Commit();
        }

    }

when I execute it, it seems that the landxmlin command fails and returns the eInvalidInput Exception.

So I want to ask is there any other way can display the landxml (with full properties), or how to fix the above code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2025-01-23 09:51:03

尝试使用 .AeccLandXmlOutNoDialog 进行导出,使用 .AeccLandXmlInNoDialog 进行导入。请注意命令名称之前的 .

edf.Command(".AeccLandXmlInNoDialog", sFileName);

Try .AeccLandXmlOutNoDialog for export and .AeccLandXmlInNoDialog for import. Notice . before command name.

edf.Command(".AeccLandXmlInNoDialog", sFileName);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文