Message 1 of 5
Rebar Location Controlling
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone!
I try to create rebar using API, I choose CreateFromRebarShape Method for Creation. And I successfully created the rebar
but one thing, rebar which I have created is always placing outside of the host and I can't able to control the location of
rebar and its layout. Can anybody help in solving this.
I have attached my code and error image below.
#region Create Reabar in Shape Method
using (Transaction createRebar = new Transaction(revitDoc, "Create Rebar"))
{
createRebar.Start();
//Pick Host Element
Reference hostElementReference = revitUi.Selection.PickObject(ObjectType.Element);
Element hostElement = revitDoc.GetElement(hostElementReference);
//Select Planar Face to Place Rebar
Reference selectedRefer = revitUi.Selection.PickObject(ObjectType.Face);
PlanarFace plane=revitDoc.GetElement(selectedRefer).GetGeometryObjectFromReference(selectedRefer) as PlanarFace;
//Get Rebar Shape
RebarShape rebarShape = new FilteredElementCollector(revitDoc).OfClass(typeof(RebarShape)).Where(x => x.Name.Equals("M_08")).FirstOrDefault() as RebarShape;
//Get Rebar Type
RebarBarType rebarType = new FilteredElementCollector(revitDoc).OfClass(typeof(RebarBarType)).OfCategory(BuiltInCategory.OST_Rebar).Where(x => x.Name.Equals("10M")).FirstOrDefault() as RebarBarType;
//Create Rebar
Rebar bar = Rebar.CreateFromRebarShape(revitDoc, rebarShape, rebarType, hostElement, plane.Origin, plane.XVector, plane.YVector);
//Create Layout
RebarShapeDrivenAccessor rebarShapeDrivenAccessor = bar.GetShapeDrivenAccessor();
rebarShapeDrivenAccessor.SetLayoutAsFixedNumber(10, UnitUtils.ConvertToInternalUnits(1800, DisplayUnitType.DUT_MILLIMETERS), true, true, true);
createRebar.Commit();
}
#endregion
Error Images