public static void createSheetList(ExternalCommandData cmd)
{
UIApplication uiapp = cmd.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Autodesk.Revit.DB.Document doc = uidoc.Document;
string[] datas = {"1,sheet1","2,sheet2","3,sheet3" };
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfCategory(BuiltInCategory.OST_TitleBlocks);
collector.WhereElementIsElementType();
//Get ElementId of first title block type.
ElementId titleBlockId = collector.FirstElementId();
using( Transaction t = new Transaction(doc, "Create Sheets"))
{
t.Start();
foreach(string csvLine in datas)
{
char[] separator = new char[] { ',' };
string[] values = csvLine.Split(separator, StringSplitOptions.None);
// Make sure both values are valid
if (values[0] != null && values[0].Length > 0 && values[1] != null && values[1].Length > 0)
{
ViewSheet sheet = ViewSheet.Create(doc, titleBlockId);
sheet.Name = values[1];
sheet.SheetNumber = values[0];
}
}
t.Commit();
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น