Download Revit 2013 API Developer Guide - The Building Coder

Transcript
}
FilteredElementCollector collector = new FilteredElementCollector(document);
Floor floor = collector.OfClass(typeof(Floor)).FirstElement() as Floor;
if (floor != null)
{
FamilySymbolSetIterator symbolItor = family.Symbols.ForwardIterator();
int x = 0, y = 0;
int i = 0;
while (symbolItor.MoveNext())
{
FamilySymbol symbol = symbolItor.Current as FamilySymbol;
XYZ location = new XYZ(x, y, 0);
XYZ direction = new XYZ();
switch (i % 3)
{
case 0:
direction = new XYZ(1, 1, 0);
break;
case 1:
direction = new XYZ(0, 1, 1);
break;
case 2:
direction = new XYZ(1, 0, 1);
break;
}
FamilyInstance instance = document.Create.NewFamilyInstance(location, symbol, direction, floor,
StructuralType.NonStructural);
x += 10;
i++;
}
}
else
{
throw new Exception("Please open a model with at least one floor element before invoking this command.");
}
The result of the previous code appears in the following picture: