Revit二次开发之创建梯形墙体

mac2025-01-25  39

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.Attributes; using Autodesk.Revit.UI.Selection; namespace ClassLibrary1 { [Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(RegenerationOption.Manual)] public class GetElement : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uidoc = commandData.Application.ActiveUIDocument; Document doc = uidoc.Document; Selection selection = uidoc.Selection; #region 创建梯形墙体 IList<Curve> curves = new List<Curve>(); Line l1 = Line.CreateBound(XYZ.Zero, new XYZ(150, 0, 0)); Line l2 = Line.CreateBound(XYZ.Zero, new XYZ(50, 0, 50)); Line l3 = Line.CreateBound(new XYZ(50, 0, 50), new XYZ(100, 0, 50)); Line l4 = Line.CreateBound(new XYZ(100, 0, 50), new XYZ(150, 0, 0)); curves.Add(l1); curves.Add(l2); curves.Add(l3); curves.Add(l4); using (Transaction ts = new Transaction(doc)) { ts.Start("创建梯形墙体"); Wall.Create(doc, curves, false); ts.Commit(); } #endregion return Result.Succeeded; } } }

最新回复(0)