Message 1 of 2

Not applicable
03-10-2015
06:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I created this macro for ordering Architecture sheets in Revit 2015. When I first created it there was no errors when i built it, and I was able to use the macro on a project. Now it is no longer working. The error is that 'i' does not exist in the current context. I have used the same structure for another macro for sheets, the only difference is that i am now using .StartsWith() instead of the string equaling a value. Can anyone help?
using(Transaction trans = new Transaction(doc, "Rename Sheets")) { FilteredElementCollector sheetView = new FilteredElementCollector(doc).OfClass(typeof(ViewSheet)); trans.Start(); foreach (Element e in sheetView) { try { ViewSheet Sheet = e as ViewSheet; { int i=0; i++; Parameter paramsheetlist = Sheet.LookupParameter("Sheet Number"); string sheetOrders = paramsheetlist.AsString(); if(sheetOrders.StartsWith("AD")){ i=1; }else { i=2;} } Parameter paramArch = Sheet.LookupParameter("Sheet Order"); paramArch.Set(i); } catch(Exception) { } } trans.Commit();
Solved! Go to Solution.