1. Parametric Model with Revit API
In this project, I created a blind for my parametric model. Since it may be cumbersome to manually install all the blinds for a building, I developed a C# tool that can install customized blinds for each window automatically. The blinds can change its size and number of blades depending on the window width and height. The two figures below show how the C# tool works.
Figure 1. Before installing blinds
The blind width and blind height were set as instance parameters, so that it could be adjusted for each window individually. Since the blind angle parameter was set as a type parameter, the blinds in the figure have the same blade angle. The figures below show how the tool can be used for a real building model.
Figure 3. Before installing blinds
The figures below show the blind model that I have developed using the wall based generic model. The blind consists of blades and a rail on top. The blades were created as an array. As mentioned above, the width and height of the blind were set as instance parameters, and the angle parameter was set as a type parameter. The number of blades depends on the blade thickness and blind height.
Figure 7. Parametric blind model (Left view)
2. BIM with Web and DB
I have linked my building model to the provided web based application template to display my building model information. In this way, users can access building information through the web. The files that I had to create and export were *.rvt, *.dwfx, and *.mdb. After modifying the *.html file, I was able to display the building information.
Figure 8. File structure for web-based application
Figure 10. Pop-up window when one of the windows is clicked by mouse. The window provides additional information of the selected element.
Figure 11. When a window is clicked the SQL query is displayed and a table extracted from the database file is shown. The table shows at which level the windows are installed at.
Figure 11. When a window is clicked the SQL query is displayed and a table extracted from the database file is shown. The table shows at which level the windows are installed at.
Figure 12. Pop-up window when one of the doors is clicked by mouse
Figure 13. Another example of the SQL query and its resulting table. The table shows the door information
3. BIM with UI and DB
I have modified the program in part 1 so that a user can control the C# tool. Through a dialog, the user can specify which level will the blinds be installed.
Figure 14. A dialog asking for the level numberFigure 15. A dialog showing information associated with the specified level. The information is retrieved from a csv file.
Figure 16. The result of applying the modified tool. The blinds are only installed on level 1.
Figure 17. Another example of the dialog asking for level number
Figure 18. The dialog showing different information from the previous one. The information is retrieved from a csv file.
Figure 19. The result of applying the modified tool. This time, the blinds are only installed on level 2.
4. Code
<Blind Type>
// Blind Type
FamilySymbol blindType = null;
ICollection<Element> families = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).ToElements();
foreach (FamilySymbol familyType in families)
{
if (familyType.Name == "Blind")
{
blindType = familyType;
}
}
<Level 1 &2 Blind Installation>
// User input dialog
Form1 form1 = new UserDefinedParameterReadWrite.CS.Form1();
form1.ShowDialog();
// Install Blind (on selected level windows)
ICollection<Element> windows = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_Windows).ToElements();
foreach (FamilyInstance win in windows)
{
ElementId levelId;
if (levelNo == 1 && win.Level.Name == "Level 1")
{
levelId = new ElementId(30);
// Window Dimension
ElementId typeId = win.GetTypeId();
ElementType winType = doc.get_Element(typeId) as ElementType;
Parameter winHeight = winType.get_Parameter("Height");
Parameter winWidth = winType.get_Parameter("Width");
// Window Location
Level level = doc.get_Element(levelId) as Level;
LocationPoint winLocPoint = win.Location as LocationPoint;
XYZ newPoint = winLocPoint.Point;
// Install Blind
FamilyInstance blind3 = doc.Create.NewFamilyInstance(newPoint, blindType, win.Host, level, StructuralType.NonStructural);
Parameter blindWidth = blind3.get_Parameter("Blinds Width");
Parameter blindHeight = blind3.get_Parameter("Height");
blindWidth.Set(winWidth.AsDouble());
blindHeight.Set(winHeight.AsDouble());
}
else if (levelNo == 2 && win.Level.Name == "Level 2")
{
levelId = new ElementId(9946);
// Window Dimension
ElementId typeId = win.GetTypeId();
ElementType winType = doc.get_Element(typeId) as ElementType;
Parameter winHeight = winType.get_Parameter("Height");
Parameter winWidth = winType.get_Parameter("Width");
// Window Location
Level level = doc.get_Element(levelId) as Level;
LocationPoint winLocPoint = win.Location as LocationPoint;
XYZ newPoint = winLocPoint.Point;
// Install Blind
FamilyInstance blind3 = doc.Create.NewFamilyInstance(newPoint, blindType, win.Host, level, StructuralType.NonStructural);
Parameter blindWidth = blind3.get_Parameter("Blinds Width");
Parameter blindHeight = blind3.get_Parameter("Height");
blindWidth.Set(winWidth.AsDouble());
blindHeight.Set(winHeight.AsDouble());
}
}
<CVS Database>
double myDouble;
if (levelNo == 1)
{
myDouble = CsvDB(0, "Col1");
MessageBox.Show("Number of blinds installed on Level 1: " + myDouble);
}
else if (levelNo == 2)
{
myDouble = CsvDB(0, "Col2");
MessageBox.Show("Number of blinds installed on Level 2: " + myDouble);
}
retRes = Result.Succeeded;
return retRes;
}
private double CsvDB(int row, string col)
{
string csvSourceFile = typeof(Csv).Assembly.Location.Replace("CommonLibrary.dll", "BlindData.csv");
CsvDoc csv = Csv.Load(csvSourceFile, false);
return csv.Get<double>(row, col);
}
}
}
No comments:
Post a Comment