背景
本文是根据地暖专业的CAD图纸数据,生成对应的Revit模型
Json数据结构
json数据:待补充
分集水器(Boxes)
名称 | 格式 | 解释 |
Point | List[double*2] | 位置坐标(X,Y) |
Angle | Double | 旋转角度(单位:度) |
地暖管线(Curves)
线类型(Line)
名称 | 格式 | 解释 |
TyepName | String | 类型名称 |
StartPoint | List[double*2] | 起始点坐标(X,Y) |
EndPoint | List[double*2] | 结束点坐标(X,Y) |
圆弧类型(Arc)
名称 | 格式 | 解释 |
TyepName | String | 类型名称 |
StartPoint | List[double*2] | 起始点坐标(X,Y) |
EndPoint | List[double*2] | 结束点坐标(X,Y) |
Center | List[double*2] | 圆心点坐标(X,Y) |
Radius | Double | 圆半径 |
墙(Walls)
名称 | 格式 | 解释 |
StartPoint | List[double*2] | 起始点坐标(中心线) |
EndPoint | List[double*2] | 结束点坐标(中心线) |
Thicknes | Double | 墙厚度 |
门(Doors)
名称 | 格式 | 解释 |
Width | Double | 门宽(在CAD中是矩形框的长) |
Height | Double | 门高 |
Point | List[double*2] | 中点位置坐标(X,Y) |
窗(Windows)
名称 | 格式 | 解释 |
Width | Double | 窗宽(在CAD中是矩形框的长) |
Height | Double | 窗高 |
Point | List[double*2] | 中点位置坐标(X,Y) |
楼板(Floors)
名称 | 格式 | 解释 |
Points | List[List[double*2]] | 外轮廓线坐标 |
结果产物
待补充
工具
Autodesk Revit 2020
Visual Studio 2019
Revit 2020 SDK
RevitAPI.dll
RevitAPIUI.dll
实现流程图
核心API
创建墙
Wall.Create(Document, Curve, ElementId, Boolean);
Document:The document in which the new wall is created.
Curve:A curve representing the base line of the wall.
ElementId: Id of the level on which the wall is to be placed.
Boolean:If set, specifies that the wall is structural in nature.
创建门、窗
Document.Create.NewFamilyInstance(XYZ, FamilySymbol, Element, Level, StructuralType);
XYZ:The physical location where the instance is to be placed on the specified level.
FamilySymbol:A FamilySymbol object that represents the type of the instance that is to be inserted.
Element:A host object into which the instance will be embedded .
Level:A Level object that is used as the base level for the object.
StructuralType:If structural then specify the type of the component.
创建分集水器
Document.Create.NewFamilyInstance(XYZ, FamilySymbol, Level, StructuralType);
XYZ:The physical location where the instance is to be placed on the specified level.
FamilySymbol:A FamilySymbol object that represents the type of the instance that is to be inserted.
Level:A Level object that is used as the base level for the object.
StructuralType:If structural then specify the type of the component.
创建地暖管
Document.FamilyCreate.NewSweep(Boolean, ReferenceArray, SweepProfile, Int32, ProfilePlaneLocation);
Boolean:Indicates if the Sweep is Solid or Void.
ReferenceArray:The path of the sweep. The path should be reference of curve or edge obtained from existing geometry.
SweepProfile:The profile to create the new Sweep. The profile must lie in the XY plane, and it will be transformed to the profile plane automatically. This may contain more than one curve loop or a profile family. Each loop must be a fully closed curve loop and the loops must not intersect. The loop can be a unbound circle or ellipse, but its geometry will be split in two in order to satisfy requirements for sketches used in extrusions
Int32:The index of the path curves. The curve upon which the profile plane will be determined.
ProfilePlaneLocation:The location on the profileLocationCurve where the profile plane will be determined.
创建楼板
Document.Create.NewFloor(CurveArray, FloorType, Level, Boolean);
CurveArray:An array of planar lines and arcs that represent the horizontal profile of the floor.
FloorType:A floor type to be used by the new floor instead of the default type.
Level:A floor type to be used by the new floor instead of the default type.
Boolean:If set, specifies that the floor is structural in nature.
步骤
1.创建项目
2.引用RevitAPI.dll、RevitAPIUI.dll
注:RevitAPI.dll、RevitAPIUI.dll在Revit2020安装路径中可以找到
3.抽象一个父类入口BaseCommand,把所有子类要用的属性都写在父类中
4.创建子类入口FloorHeatCommand
TransactionMode分为Automatic、Manual和ReadOnly。
1.TransactionMode.Automatic:
Revit会在调用外部命令之前自动创建一个Transaction,并且该Transaction会在外面命令结朿时提交或者回滚。如果外部命令执行成功,则提交Transaction;如果有异常,则回滚。在该模式下,外部命令不能再创建自己的Transaction,但是可以创建 SubTransactions。
2.TransactionMode.Manual:
此模式表示Revit不会自动创建一个Transaction。如果用户需要修改Revit摸型,则需要自行创建Transaction,并且自行管理这个Transaction提交还是回滚。
3.TransactionMode.ReadOnly:
在该模式下,外部命令不能有任何的Transaction,否则在创建Transaction或者修改 Revit文档都会抛出异常。
5.解析CAD_Json数据
6.更改视图
7.创建一个2.8米的标高
8.遍历集水箱数据并创建
9.遍历地暖管数据进行回路分组
10.遍历分组后的地暖管数据并创建
11.遍历墙数据并创建
12.遍历门数据并创建
13.遍历窗数据并创建
14.遍历楼板数据并创建
Revit调用步骤
1.新建项目
2.附加模块——>外部工具
3.引入程序的dll
4.执行程序的dll
5.生成模型结果