I am new to revit api . I want to create a panel in revit empty project. I can create walls . I want to know how can I add panel data (studs , panel name , openings etc ) in the wall . Also I am new to construction terminologies.
here is my code:
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uiapp.ActiveUIDocument.Document;
WallType w = getWallType(doc);
RetrievingLevels(doc);
Level newLevel = CreateLevels(doc);
if(newLevel != null)
{
IList<Curve> curves = new List<Curve>();
XYZ first = new XYZ(0, 0, 0);
XYZ second = new XYZ(20, 0, 0);
XYZ third = new XYZ(20, 0, 15);
XYZ fourth = new XYZ(0, 0, 15);
curves.Add(Line.CreateBound(first, second));
curves.Add(Line.CreateBound(second, third));
curves.Add(Line.CreateBound(third, fourth));
curves.Add(Line.CreateBound(fourth, first));
//Line l = Line.CreateBound(a1, b1);
Transaction trans = new Transaction(doc);
try
{
trans.Start("create walls");
Wall.Create(doc, curves, w.Id,newLevel.Id, true);
trans.Commit();
return Result.Succeeded;
}
catch (Exception ex)
{
trans.Dispose();
return Result.Failed;
}
}
return Result.Failed;
//IList<Curve> curves = new List<Curve>();
}
private WallType getWallType(Document doc)
{
FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(WallType));
IList<Element> WallTypes = collector.ToElements();
return WallTypes.First() as WallType;
}
private Level CreateLevels(Document document)
{
double elevation = 33.0;
Transaction t = new Transaction(document);
// Begin to create a level
t.Start("create Level");
try
{
Level level = Level.Create(document, elevation);
if (null == level)
{
throw new Exception("Create a new level failed.");
}
// Change the level name
level.Name = "New level";
t.Commit();
return level;
}
catch (Exception e)
{
}
return null;
}
Also please suggest me from where can I learn about revit APIS .