我正在Revit中的一个项目中,我需要创建四个墙,其中两个是基本墙,另外两个是玻璃墙(在revit中,玻璃墙称为幕墙-如果我错了,请纠正我)。我能够实现这一点,但是输出存在一些问题。以下是我的代码:在这里我得到了四点。
double width = UnitUtils.ConvertToInternalUnits(2500, DisplayUnitType.DUT_MILLIMETERS);
double depth = UnitUtils.ConvertToInternalUnits(1200, DisplayUnitType.DUT_MILLIMETERS);
List<XYZ> corners = new List<XYZ>(4);
corners.Add(XYZ.Zero);
corners.Add(new XYZ(width, 0, 0));
corners.Add(new XYZ(width, depth, 0));
corners.Add(new XYZ(0, depth, 0));
这里我根据这些点画墙。这里levelBottomId是最低级别
for (int i = 0; i < 4; ++i)
{
Line line = Line.CreateBound(corners[i], corners[3 == i ? 0 : i + 1]);
Wall wall = Wall.Create(doc, line, levelBottomId, false);
//add materials to walls to create basic wall or glass wall as per condition
}
我创建基本墙面材料的代码如下:
WallType walltype = wall.WallType;
var newWallType = walltype.Duplicate(wallName)
var compStruct = newWallType.GetCompoundStructure();
var wallLayers = compStruct.GetLayers();
//add materials
compStruct.SetLayers(wallLayers);
newWallType.SetCompoundStructure(compStruct);
wall.WallType = newWallType;
我创建玻璃墙的代码如下:
List<WallType> wallTypeList = new FilteredElementCollector(doc).OfClass(typeof(WallType)).OfType<WallType>().ToList();
WallType walltype = null;
foreach (var wt in wallTypeList)
{
if (wt.Kind == WallKind.Curtain){
walltype = wt;
break;
}
}
var newWallType = walltype.Duplicate(wallName) as WallType;
wall.WallType = newWallType;
请先研究最佳实践和最佳工作流程以在用户界面中手动解决此问题,然后再开始进行编程方面的工作。