LoadCase
是 Revit 结构中用于存储结构负载的类。
namespace Autodesk.Revit.DB.Structure
{
public class LoadCase : Element
}
Element
public LoadCase(Document document, ElementId id)
public LoadCase(Document document, LoadCaseType loadCaseType)
public LoadCase(Document document, LoadCaseType loadCaseType, string name)
document
: Document - Revit 中的文档实例对象id
: ElementId - 要求新创建对象具有的唯一标识符loadCaseType
: LoadCaseType - 所创建荷载组的类型name
: string - 创建荷载组名称 public string Name { get; }
public LoadCaseType LoadCaseType { get; }
public void AddLoad(LoadBase load)
load
: LoadBase - 添加的荷载对象实例。public IList<LoadBase> GetLoads()
public void SetLoads(IList<LoadBase> loads)
获取全部荷载组
public void GetAllLoadCases(Document doc)
{
FilteredElementCollector loadCaseCollector = new FilteredElementCollector(doc);
loadCaseCollector.OfClass(typeof(LoadCase));
foreach (LoadCase loadCase in loadCaseCollector)
{
TaskDialog.Show("Load Case", loadCase.Name);
}
}
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
public void ShowLoadCaseExample(Document doc)
{
// 获取Beam类族
ElementClassFilter beamFilter = new ElementClassFilter(typeof(FamilyInstance));
//获取到Beam标注族的实例
FilteredElementCollector beamCollector = new FilteredElementCollector(doc);
beamCollector.WherePasses(beamFilter);
FamilyInstance firstBeam = beamCollector.FirstElement() as FamilyInstance;
// 检测是否指定的柱子;
if (firstBeam == null || !firstBeam.Symbol.Family.Name.Contains("Concrete"))
{
TaskDialog.Show("Revit", "请先在Revit中选择名字中包含'Concrete'字样的Beam实例!");
return;
}
// 创建荷载组
LoadCaseType deadLoadCaseType = LoadCaseType.Dead;
LoadCase loadCase = new LoadCase(doc, deadLoadCaseType, "My First Load Case");
// 创建负载
PointLoad pointLoad = new PointLoad(new XYZ(0, 0, -50), new XYZ(0, 0, 1), 500, 1);
//将PointLoad添加到荷载组中
loadCase.AddLoad(pointLoad);
// 将PressureLoad添加到荷载组中
PressureLoad pressureLoad = new PressureLoad(new XYZ(0, 0, -500), new XYZ(0, 0, 1), 1000, 1);
loadCase.AddLoad(pressureLoad);
// 在Beam上应用荷载
LoadApplicationOptions loadApplicationOptions = new LoadApplicationOptions(FootPrintRoofSlopeType.RoofSlope);
loadApplicationOptions.SetMinidumpFilePath(@"c:\temp");
LoadInPlaceResult result = LoadInPlaceUtils.ApplyLoad(doc, firstBeam, loadCase, loadApplicationOptions);
// 显示结果
string message = "荷载应用成功";
switch (result)
{
case LoadInPlaceResult.AppliedLoadsCannotCreateSupports:
message = "载荷已成功应用,但未能同时创建支撑!";
break;
case LoadInPlaceResult.AppliedLoadsHasSupportsNotCreated:
message = "载荷已成功应用,并创建了支撑构件";
break;
default:
break;
}
TaskDialog.Show("Revit", message);
}