Message 1 of 16
Not applicable
05-13-2016
09:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attemtping to programmatically place walls, and then place doors and windows in those walls.
I am getting confused about how to generate a FamilySymbol for a door. I am assuming that window insertion into walls is similar in technique.
code is below:
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB;
using Autodesk.Revit.Creation;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
[TransactionAttribute( TransactionMode.Manual )]
[RegenerationAttribute( RegenerationOption.Manual )]
public class RevitDataPlugin : IExternalCommand {
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements ) {
//Get application and document objects
UIApplication uiApp = commandData.Application;
var doc = uiApp.ActiveUIDocument.Document;
using ( Transaction trans = new Transaction( doc ) ) {
trans.Start( "WallDataParser" );
Level level = Level.Create( doc, 0.0 );
XYZ start = new XYZ( 0.0, 0.0, 0.0 );
XYZ end = new XYZ( 10.0, 0.0, 0.0 );
Line wallLine = Line.CreateBound( start, end );
Wall wall = Wall.Create( doc, wallLine as Line, level.Id, true );
XYZ doorPoint = new XYZ( 5.0 , 0.0, 0.0 );
ElementId doorCategoryId = new ElementId( BuiltInCategory.OST_Doors );
FamilySymbol doorSymbol = null; // TODO: how?
doc.Create.NewFamilyInstance( doorPoint, doorSymbol, wall, Autodesk.Revit.DB.Structure.StructuralType.NonStructural );
doc.Regenerate();
trans.Commit();
}
return Result.Succeeded;
}
}
Solved! Go to Solution.