当我试图创建一个钢筋容器时,运行完以下命令后,我在Revit中得到了这个错误:
警告-可以忽略 “钢筋容器完全放置在主机之外。”
我不知道该如何避免这个错误。以下是代码:
containertype = RebarContainerType.
GetOrCreateRebarContainerType(Doc, "myContainer");
container = RebarContainer.Create(Doc, hostObject, containertype);发布于 2016-04-08 20:09:46
每个RebarContainer包含RebarContainerItem对象的集合(第一次创建时为空)。RebarContainerItem提供了类似于Rebar元素的属性和方法。
您可以使用静态方法。
RebarContainer.Create() 它需要要创建新RebarContainer的文档、将承载新RebarContainer的主机元素和将分配给新RebarContainer的RebarContainerType的ElementId。
下面是创建钢筋容器的代码。
void AddItemsToRebarContainer(RebarContainer container, FamilyInstance beam,
RebarBarType barType, RebarHookType hookType)
{
// Define the rebar geometry information - Line rebar
LocationCurve location = beam.Location as LocationCurve;
XYZ origin = location.Curve.GetEndPoint(0);
// create rebar along the length of the beam
XYZ rebarLineEnd = location.Curve.GetEndPoint(1);
Line line = Line.CreateBound(origin, rebarLineEnd);
XYZ normal = new XYZ(1, 0, 0);
Curve rebarLine = line.CreateOffset(0.5, normal);
// Create the line rebar
IList<Curve> curves = new List<Curve>();
curves.Add(rebarLine);
RebarContainerItem item = container.AppendItemFromCurves
(RebarStyle.Standard, barType, hookType, hookType, normal,
curves, RebarHookOrientation.Right, RebarHookOrientation.Left, true, true);
if (null != item)
{
// set specific layout for new rebar as fixed number, with 10 bars,
// distribution path length of 1.5'
// with bars of the bar set on the same side of the rebar plane as
// indicated by normal and both first and last bar in the set are shown
item.SetLayoutAsFixedNumber(10, 1.5, true, true, true);
}
}请原谅我错误的代码格式。这是我第一次在Stack overflow中发表文章:)
https://stackoverflow.com/questions/34582539
复制相似问题