using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WallCreat
{
[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
IList<Curve> curves = new List<Curve>();
XYZ p1 = new XYZ(0, 0, 0);
XYZ p2 = new XYZ(3, 0, 5);
XYZ p3 = new XYZ(0, 0, 10);
Curve line1 = Line.CreateBound(p1,p2);
Curve line2 = Line.CreateBound(p2,p3);
Curve line3 = Line.CreateBound(p3, p1);
curves.Add(line1);
curves.Add(line2);
curves.Add(line3);
ElementId wallTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.WallType);
ElementId levelId = doc.ActiveView.GenLevel.Id;
Plane wallPlane = Plane.CreateByThreePoints(p1, p2, p3);
XYZ normal = wallPlane.Normal;
Transaction transaction = new Transaction(doc, "创建异形墙");
transaction.Start();
Wall wall = Wall.Create(doc, curves, wallTypeId, levelId, true, normal);
transaction.Commit();
return Result.Succeeded;
}
}
}
创建异形墙
最新推荐文章于 2022-11-11 23:00:32 发布