仅提供English版本
Data volume of components in revit is large. Database is needed when doing standardization or audit software. Importing data into database enables calculation to verify separated from software, which is also a kind of burden reduction for alternative software.
demo
Get component - Test project casually select several components to output data
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
var refer = uidoc.Selection.PickObjects(ObjectType.Element, "pick onjects");
List<string> categorys = new List<string>();
List<int> elementIds = new List<int>();
List<string> symbolNames = new List<string>();
foreach(Reference re in refer)
{
Element e = doc.GetElement(re);
string symbolName = e.Name;
string category = e.Category.Name;
int elementId = e.Id.IntegerValue;
symbolNames.Add(symbolName);
categorys.Add(category);
elementIds.Add(elementId);
}Connect to Database
- Because it is a test, mysql connection is set to local connection. This step should be creating Mysql file to transfer to server database for reading
1 | public MySQLConnection2(List<int> elementids,List<string> symbolNames,List<string> categorys) |
- Display in form. Frontend code is relatively simple, just pass data stream in
1 |
|

Up to this step data can be extracted and utilized, but empty rows or empty columns will appear in datagrid of frontend. Need to set parametersdataGridView1.AllowUserToAddRows = false; change value to false. Reference link: https://blog.csdn.net/wanglejun/article/details/39231075
Author: Broccoli
Copyright Notice: All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Related Articles

2020-11-11
Revit Export DWGExportSetting
2020-01-19
2016RevitAPI一次性生成多个构件
2020-07-02
revit Secondary Development Idling&ExternalEvent
2021-06-08
Revit PromptForFamilyInstancePlacementOptions Family Placement API

2021-01-05
Revit Left Right Value Coding Storage Hierarchical Tree Structure Design

2021-09-14
QT+ CLion + Revit Issues Summary