namespace CreateTables
{
[Transaction(TransactionMode.Manual)]
public class Command : 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;
Selection sel = uidoc.Selection;
Reference ref1 = sel.PickObject(ObjectType.Element, "Please pick a Wall");
Wall wall = doc.GetElement(ref1) as Wall;
CreateDoorsInWall(doc, wall);
return Result.Succeeded;
}
private void CreateDoorsInWall(Document doc, Wall wall)
{
String fileName = @"C:\Program Files\Common Files\Autodesk Shared\Extensions 2013\Data\Families\Profiles\DB\Beam\DB_Beam_UAP.rfa";
Family family = null;
if (!doc.LoadFamily(fileName, out family))
{
throw new Exception("Unable to load" + fileName);
}
//get the active view's level for beam creation
Level level = doc.ActiveView.Level;
FamilySymbolSetIterator symbolItor = family.Symbols.ForwardIterator();
double x = 0, y = 0, z = 0;
while (symbolItor.MoveNext())
{
FamilySymbol symbol = symbolItor.Current as FamilySymbol;
XYZ location = new XYZ(x, y, z);
FamilyInstance instance = doc.Create.NewFamilyInstance(location, symbol,
wall, level, StructuralType.NonStructural);
x += 10;
y += 10;
z += 1.5;
}
}
}
}
<Revit二次开发> Create Doors in Wall
最新推荐文章于 2024-08-18 12:15:00 发布