Message 1 of 5

Not applicable
10-10-2018
05:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I thought that I solved the puzzle but I keep getting it wrong.
The code:
namespace Prototype.Forms { /// <summary> /// Interaction logic for UserForm.xaml /// </summary> public partial class UserForm : UserControl { public Document UserDoc; public IList<View3D> viewList = new List<View3D>(); public UserForm(Document doc, String switchCase) { InitializeComponent(); FilteredElementCollector collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views); collector.OfClass(typeof(View3D)); foreach (View3D v in collector) { if (v.CanBePrinted == true) { viewList.Add(v); } } UserDoc = doc; private void Export_Click(object sender, RoutedEventArgs e) { foreach (View3D v in viewList) { if(v.CanBePrinted == true) { DWGExport(UserDoc, v); } } } public void DWGExport(Document doc, View view) { DWGExportOptions opt = new DWGExportOptions(); ICollection<ElementId> views = new List<ElementId> { view.Id }; try { doc.Export(System.IO.Path.GetDirectoryName(doc.PathName), view.Name, views, opt); } catch (Exception e) { TaskDialog.Show("Error Caught", e.ToString()); } } } public class DataItem { public Boolean Select { get; set; } public String ViewName { get; set; } public String Type { get; set; } } }
In short I filter for View3D elements add them to the viewList then I've assigned a button to export all the View3D to DWG by way View3D ElementID.
I do manage to export a view which happens to be the active view but not the rest of the views, I've also checked that the viewList.Count is greater then 1 and it is.
Any help would be appreciated!
Solved! Go to Solution.