不廢話,直接上源代碼。
如果有設置了二維視圖的生成設置,請添加setupName進行過濾。如果沒有,請直接按第一個設置選項導出。
private bool ExportDWGF(Document document,View view,string setupName)
{
bool exported = false;
IList<string> setupNames = BaseExportOptions.GetPredefinedSetupNames(document);
foreach(string name in setupNames)
{
// if(name.CompareTo(setupName)==0)
// {
DWGExportOptions dwgOptions = DWGExportOptions.GetPredefinedOptions(document, name);
ICollection<ElementId> views = new List<ElementId>();
views.Add(view.Id);
exported = document.Export(Path.GetDirectoryName(document.PathName), Path.GetFileNameWithoutExtension(document.PathName),
views, dwgOptions);
break;
// }
}
return exported;
}