Revit二次开发 将构件信息导入到数据库中
仅提供中文版本
revit中构件数据量较大,在做标准化或者审核软件的时候需要用到数据库,将数据导入数据库使得计算能够脱离软件进行计算也算是一种另类的软件减负
demo
获取构件-测试项目随便框选几个构件进行输出数据
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);
}连接数据库
- 因为是测试所以将mysql连接设置为本地连接,这一步应该是创建Mysql文件传递到服务器数据库中进行读取
1 | public MySQLConnection2(List<int> elementids,List<string> symbolNames,List<string> categorys) |
- 在form中显示 前端代码相对简单将数据流传入即可
1 |
|

到这一步便可以将数据提取进行利用,但是前端这块datagrid会出现空行或者空列,需要设置一下参数dataGridView1.AllowUserToAddRows = false;将值改为false即可。参考链接:https://blog.csdn.net/wanglejun/article/details/39231075
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.




