private static void ExportViewsProcessLoop(Document doc, string source_path, List <List <string> > category_cols, string target_folder) { string proj_Name = doc.ProjectInformation.Name; StringBuilder sb = new StringBuilder(); FilteredElementCollector viewsCol = new FilteredElementCollector(doc) .WhereElementIsNotElementType() .OfCategory(BuiltInCategory.OST_Views); ElementId pattern = new FilteredElementCollector(doc) .OfClass(typeof(FillPatternElement)).FirstElementId(); sb.AppendLine(); sb.Append("PROJECT--:" + proj_Name); ViewType[] types = { ViewType.AreaPlan, ViewType.CeilingPlan, ViewType.Detail, ViewType.Elevation, ViewType.EngineeringPlan, ViewType.FloorPlan, ViewType.Section }; foreach (View view in viewsCol) { if (types.Contains(view.ViewType) || view.ViewType == ViewType.ThreeD) { makeAnnoOverrides(doc, view, category_cols); viewOptions(doc, view); Applicator.AddOverride(doc, view, pattern, category_cols); } } }
public static void JpegsFromSheets(Document doc, string target_folder, List <List <string> > category_cols) { List <Category> tohide = GetCategoriesToHide(doc, category_cols); List <ViewSheet> AllSheets = Helper.GetAllT <ViewSheet>(doc); DocPatterns docpatterns = new DocPatterns(doc); List <OverrideCat> tohideOverride = GetCategoryOverrides(doc, docpatterns, category_cols); foreach (ViewSheet vs in AllSheets) { if (!vs.IsTemplate && vs.CanBePrinted && vs.ViewType == ViewType.DrawingSheet) { Applicator.ExportViewIfNoExists(doc, vs, target_folder, "---base"); List <ElementId> viewsInSHeet = vs.GetAllPlacedViews().ToList(); var base_export_loc = target_folder + Helper.AndHash(vs.Name) + "---mask" + vs.Name; if (!File.Exists(base_export_loc + ".png")) { foreach (ElementId viewid in viewsInSHeet) { View view = doc.GetElement(viewid) as View; OverrideView(doc, view, tohideOverride, tohide); } Applicator.ExportViewIfNoExists(doc, vs, target_folder, "---mask"); } } } }
private static void ExportSheetsProcessLoop(Document doc, string source_path, List <List <string> > category_cols, string target_folder) { string proj_Name = doc.ProjectInformation.Name; StringBuilder sb = new StringBuilder(); FilteredElementCollector viewsCol = new FilteredElementCollector(doc) .WhereElementIsNotElementType() .OfCategory(BuiltInCategory.OST_Views); var docpatterns = new DocPatterns(doc); ViewType[] types = { ViewType.AreaPlan, ViewType.CeilingPlan, ViewType.Detail, ViewType.Elevation, ViewType.EngineeringPlan, ViewType.FloorPlan,ViewType.Section, ViewType.ThreeD }; foreach (View view in viewsCol) { if (types.Contains(view.ViewType)) { makeAnnoOverrides(doc, view, category_cols); viewOptions(doc, view); Applicator.AddOverride(doc, view, docpatterns.Solidfill, category_cols); } } }
private static void JpegsFromSheets(Document doc, string target_folder, List <List <string> > category_cols) { List <ViewSheet> AllSheets = Helper.GetAllSheets(doc); var docpatterns = new DocPatterns(doc); foreach (ViewSheet vs in AllSheets) { List <ElementId> viewsInSHeet = vs.GetAllPlacedViews().ToList(); //Base export Applicator.ExportViewIfNoExists(doc, vs, target_folder, "---base"); var base_export_loc = target_folder + Helper.SheetFileName(vs, "---mask"); if (!File.Exists(base_export_loc + ".png")) { //create overrides foreach (ElementId viewid in viewsInSHeet) { View view = doc.GetElement(viewid) as View; OverrideView(doc, view, docpatterns, category_cols); } //Second Export Applicator.ExportViewIfNoExists(doc, vs, target_folder, "---mask"); } } }
private static void SheetsToCsv(Document doc, string target_folder) { List <ViewSheet> AllSheets = Helper.GetAllSheets(doc); StringBuilder sb = new StringBuilder(); if (AllSheets.Count() > 0) { sb.AppendLine( String.Format("{0},{1},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17}", "file-name", "sheet-hash", "view-hash", "sheet-name", "sheet-number", "sheet-width", "sheet-height", "view-name", "view-min-x", "view-max-x", "view-min-y", "view-max-y", "label-min-x", "label-max-x", "label-min-y", "label-max-y", "view-type", "view-scale")); foreach (ViewSheet vs in AllSheets) { try { sb = Applicator.ExportSheetStats(doc, vs, sb); } catch (Exception) { } } File.WriteAllText(target_folder + "sheet_data.csv", sb.ToString()); } }
private static void SheetsToJpeg(Document doc, string target_folder, string ext) { ViewSet myViewSet = new ViewSet(); var collector = Helper.GetAllSheets(doc); foreach (ViewSheet vs in collector) { var view_export_loc = target_folder + Helper.AndHash(vs.Name) + ext + vs.Name; if (!File.Exists(view_export_loc + ".png")) { Applicator.ExportView(doc, vs, view_export_loc, ext); } } }
private static void OverrideView(Document doc, View view, DocPatterns docpatterns, List <List <string> > category_cols, bool elemovr = true) { ViewType[] types = { ViewType.AreaPlan, ViewType.CeilingPlan, ViewType.Detail, ViewType.Elevation, ViewType.EngineeringPlan, ViewType.FloorPlan,ViewType.Section, ViewType.ThreeD }; if (types.Contains(view.ViewType)) { makeAnnoOverrides(doc, view, category_cols); if (elemovr == true) { viewOptions(doc, view); Applicator.AddOverride(doc, view, docpatterns.Solidfill, category_cols); } } }
private void test1(Document doc) { var category_colors = FileManager.ReadDefCsv(FileManager.data_location); DocPatterns patterns = new DocPatterns(doc); List <OverrideCat> rcs = new List <OverrideCat>(); //foreach (var cs in category_colors) //{ // OverrideCat cst = new OverrideCat(patterns.Solidfill, cs); // rcs.Add(cst); //} //FilteredElementCollector collec = new FilteredElementCollector(doc, doc.ActiveView.Id); //var collector // = collec.WheToElements() // .Select(x => x.Category) // .Distinct(new CategoryComparer()) // .ToList(); var iter = doc.Settings.Categories; //doc.Settings.Categories.AsQueryable(); // iter.MoveNext(); foreach (Category cat in iter) { try { // iter.C BuiltInCategory curcat = (BuiltInCategory)cat.Id.IntegerValue; //doc.Settings.Categories string ccat = curcat.ToString(); var found = category_colors.Where(x => x.First() == ccat); OverrideCat cst; if (found.Count() > 0) { cst = new OverrideCat(doc, patterns.Solidfill, found.First()); } else { cst = new OverrideCat(patterns.Dotline, curcat); cst.visible = false; } rcs.Add(cst); // iter.MoveNext(); } catch (Exception) { } } var viewsCol = new FilteredElementCollector(doc) .WhereElementIsNotElementType() .OfCategory(BuiltInCategory.OST_Views) .ToElements().Cast <View>().ToList(); var watch = Stopwatch.StartNew(); foreach (var vs in viewsCol) { string ext1 = "---base---"; string ext2 = "---mask---"; string view_export_loc1 = "C:\\data\\t1\\" + Helper.AndHash(vs.Name) + ext1 + vs.Name; string view_export_loc2 = "C:\\data\\t1\\" + Helper.AndHash(vs.Name) + ext2 + vs.Name; Applicator.ExportView(doc, vs, view_export_loc1, ext1); var rvs = Applicator.viewCatOverride(doc, vs, rcs); Applicator.ExportView(doc, rvs, view_export_loc2, ext2); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; //uiapp.OpenAndActivateDocument(paths[1]); //doc.Close(false); //var watch2 = Stopwatch.StartNew(); //foreach (var vs in viewsCol) //{ // string ext1 = "---base---"; // string ext2 = "---mask---"; // string view_export_loc1 = "C:\\data\\t2\\" + Helper.AndHash(vs.Name) + ext1 + vs.Name; // string view_export_loc2 = "C:\\data\\t2\\" + Helper.AndHash(vs.Name) + ext2 + vs.Name; // Applicator.ExportView(doc, vs, view_export_loc1, ext1); // Applicator.AddOverride(doc, vs, patterns.Solidfill, category_colors); // Applicator.ExportView(doc, vs, view_export_loc2, ext2); //} //watch2.Stop(); //var elapsedMs2 = watch2.ElapsedMilliseconds; TaskDialog.Show("opt", "base " + elapsedMs.ToString()); }