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 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()); }