Created
March 22, 2017 05:05
-
-
Save benkoshy/487b2ed0599975f860dcff43d9efa77f to your computer and use it in GitHub Desktop.
Create wall Example updated to 2017 - (Untested code WARNING)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CreateRevitPanel | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Autodesk.Revit.DB; | |
using Autodesk.Revit.DB.Architecture; | |
using Autodesk.Revit.UI; | |
using Autodesk.Revit.UI.Selection; | |
using Autodesk.Revit.ApplicationServices; | |
using Autodesk.Revit.Attributes; | |
using Autodesk.AutoCAD.Geometry; | |
[TransactionAttribute(TransactionMode.Manual)] | |
[RegenerationAttribute(RegenerationOption.Manual)] | |
public class Lab1PlaceGroup : IExternalCommand | |
{ | |
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) | |
{ | |
UIApplication uiapp = commandData.Application; | |
UIDocument uidoc = uiapp.ActiveUIDocument; | |
Application app = uiapp.Application; | |
Document doc = uidoc.Document; | |
// Build a wall profile for the wall creation | |
XYZ[] pts = new XYZ[] { | |
XYZ.Zero, | |
new XYZ( 20, 0, 0 ), | |
new XYZ( 20, 0, 15 ), | |
new XYZ( 10, 0, 30 ), | |
new XYZ( 0, 0, 15 ) | |
}; | |
// Get application creation object | |
Autodesk.Revit.Creation.Application appCreation = app.Create; | |
// Create wall profile | |
//CurveArray profile = new CurveArray(); | |
IList<Curve> profile = new List<Curve>(); | |
XYZ q = pts[pts.Length - 1]; | |
foreach (XYZ p in pts) | |
{ | |
profile.Add(Line.CreateBound(q, p)); | |
q = p; | |
} | |
XYZ normal = XYZ.BasisY; | |
WallType wallType = new FilteredElementCollector(doc) | |
.OfClass(typeof(WallType)) | |
.First<Element>() | |
as WallType; | |
Level level = new FilteredElementCollector(doc) | |
.OfClass(typeof(Level)) | |
.First<Element>(e => e.Name.Equals("Level 1")) | |
as Level; | |
Transaction trans = new Transaction(doc); | |
trans.Start("Create Gable Wall"); | |
// Wall wall = doc.Create.NewWall(profile, wallType, level, true, normal); | |
Wall wall = Wall.Create(doc, profile, false); | |
trans.Commit(); | |
return Result.Succeeded; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment