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.
Try .AeccLandXmlOutNoDialog
for export and .AeccLandXmlInNoDialog
for import. Notice .
before command name.
edf.Command(".AeccLandXmlInNoDialog", sFileName);