Issue with Views Misalignment in MicroStation After Using Design Automation for Revit (DA4R) for DWG Export
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I am currently working on a project that uses the Design Automation for Revit (DA4R) API to convert Revit files (RVT) into DWG files. The project is based on this example https://github.com/yiskang/DA4R-DwgExporter from GitHub.
The issue I am encountering is that when I open the generated DWG files in MicroStation, the views are not aligned as they were in the original Revit file. It appears that the positioning of views in the exported DWG file is not interpreted by MicroStation the same way it is in Autodesk products.
Here is the core part of the code I'm using:
using (var transGroup = new TransactionGroup(doc, "Starts exporting DWG"))
{
try
{
transGroup.Start();
ViewSheet newViewSheet;
using (var transaction = new Transaction(doc, "Create a new ViewSheet"))
{
transaction.Start();
LogTrace("Creating a new ViewSheet...");
newViewSheet = ViewSheet.Create(doc, ElementId.InvalidElementId);
LogTrace("Iterate over each view and create a new viewport on the new ViewSheet ...");
foreach (var viewId in viewIds)
{
try
{
LogTrace("Create viewport for view: {0}", doc.GetElement(viewId).Name);
Viewport.Create(doc, newViewSheet.Id, viewId, XYZ.Zero);
}
catch (Exception e)
{
LogError(new Exception(
"Viewport creation failed for view: " + doc.GetElement(viewId).Name, e));
}
}
doc.Regenerate();
transaction.Commit();
}
if (newViewSheet == null)
{
throw new Exception("Failed to create a new ViewSheet");
}
using (var transaction = new Transaction(doc, "Starting the export task"))
{
transaction.Start();
LogTrace("Starting the export task...");
var newViewSheetIds = new List<ElementId> { newViewSheet.Id };
doc.Export(exportPath, inputParams.ExportFilename, newViewSheetIds, dwgExportOptions);
LogAllFiles(exportPath);
transaction.Commit();
}
transGroup.Assimilate();
}
catch (Exception ex)
{
LogError(ex);
transGroup.RollBack();
return false;
}
}
This code successfully combines all views into a single sheet and exports them into a DWG file. However, when the output DWG is opened in MicroStation, the views are not lined up as expected.
Has anyone else encountered this issue and can provide any insight or solutions? Your help would be greatly appreciated!
In order to better illustrate the issue, I have attached two images. The first image showcases a simple cube model with two views in Revit, demonstrating the intended layout. The second image shows the resulting layout when the exported DWG file is opened in MicroStation, highlighting the misalignment of the views.
Thank you in advance!
Best,
Hasan