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

Use Civil 3D Design Automation to convert landxml file to dwg for displaying in Forge Viewer

我想在 forge 查看器上显示 landxml 文件,但由于模型导数 API 不支持将 landxml 转换为 svf,我决定使用设计自动化将 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 命令似乎失败并且 returns eInvalidInput 异常。

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

尝试 .AeccLandXmlOutNoDialog 导出,.AeccLandXmlInNoDialog 导入。注意命令名称前的.

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