Not applicable
04-07-2017
04:37 AM
How converting simple macro to Revit API to create List Of Drawings:
/* * Created by SharpDevelop. * User: MOHAMED.moussa * Date: 4/3/2017 * Time: 3:25 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.UI.Selection; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.Revit.ApplicationServices; namespace LODCREATION { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.DB.Macros.AddInId("137BBBD9-148E-4401-913F-168FDEA677C6")] public partial class ThisDocument { private void Module_Startup(object sender, EventArgs e){ } private void Module_Shutdown(object sender, EventArgs e){ } public void LODCREATION() { UIApplication uiApp = this.Application; Application app = uiApp.Application; UIDocument uiDoc = uiApp.ActiveUIDocument; Document Doc = uiDoc.Document; StringBuilder sb = new StringBuilder(); ElementCategoryFilter sheetcf = new ElementCategoryFilter(BuiltInCategory.OST_Sheets); FilteredElementCollector sheetCollector = new FilteredElementCollector(Doc); IList<Element> sheetlist = sheetCollector.WherePasses(sheetcf).WhereElementIsNotElementType().ToElements(); foreach(Element sheet in sheetlist) { FilteredElementCollector panelCollector = new FilteredElementCollector(Doc, sheet.Id); IList<Element> panellist = panelCollector.WherePasses(panelcf).WhereElementIsNotElementType().ToElements(); sb.AppendLine(sheet.get_Parameter(BuiltInParameter.SHEET_NUMBER).AsString() + " \t"+sheet.get_Parameter(BuiltInParameter.SHEET_NAME).AsString()); } Autodesk.Revit.DB.XYZ baseVec = Document.Application.Create.NewXYZ(0.0, 0.0, 1.0); Autodesk.Revit.DB.XYZ upVec = Document.Application.Create.NewXYZ(0.0, 0.0, 1.0); Autodesk.Revit.DB.XYZ origin = Document.Application.Create.NewXYZ(0.0, 0.0, 0.0); Autodesk.Revit.DB.XYZ origin1 = Document.Application.Create.NewXYZ(0.0, 3.0, 0.0); Autodesk.Revit.DB.TextAlignFlags align = Autodesk.Revit.DB.TextAlignFlags.TEF_ALIGN_LEFT | Autodesk.Revit.DB.TextAlignFlags.TEF_ALIGN_TOP; string strText = sb.ToString(); //----------- double lineWidth = 4.0 / 12.0; Autodesk.Revit.DB.Transaction t = new Autodesk.Revit.DB.Transaction(Document, "NewTextNote"); t.Start(); Autodesk.Revit.DB.View pView = Document.ActiveView; Document.Create.NewTextNote(pView,origin1, baseVec, upVec, lineWidth, align, strText); t.Commit(); } #region Revit Macros generated code private void InternalStartup() { this.Startup += new System.EventHandler(Module_Startup); this.Shutdown += new System.EventHandler(Module_Shutdown); } #endregion } }
Excuse while it's the first Revit Macro.
Solved! Go to Solution.
Link copied