Rebar Location Controlling

Rebar Location Controlling

arshad.k
Enthusiast Enthusiast
1,455 Views
4 Replies
Message 1 of 5

Rebar Location Controlling

arshad.k
Enthusiast
Enthusiast

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

arshadk_1-1643095016407.png

arshadk_2-1643095057283.png

 

@jeremytammik @naveen.kumar.t 

0 Likes
1,456 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

I seem to remember this being discussed here in the past couple of months... I think you can find the answer by searching for "rebar cover". Good luck!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

arshad.k
Enthusiast
Enthusiast

Dear Jeremy Tammik

 

I searched, But I can't found what exactly I need. Can you guide me how to solve this...

 

@jeremy_tammik 

0 Likes
Message 4 of 5

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @arshad.k ,

 

I tested the sample code you attached.

 

I'm not getting any such errors.

 

I used this sample code
Rebar bar = Rebar.CreateFromRebarShape(doc, rebarShape, rebarType, hostElement, planeF.Origin, new XYZ(1,0,0), new XYZ(0,1,0));

 

Which Revit version are you using?

 

Could you please send us a small non-confidential reproducible sample code(I think we already have the sample code) and a simple non-confidential Revit model(rvt file) to recreate the issue?

 

Also, send us the detailed step-by-step instructions for reproducing the issue(i.e)which plane to choose


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

jeremy_tammik
Alumni
Alumni

Please refer to the thread on constraining stirrups to the cover of the host element for a complete answer:

 

https://forums.autodesk.com/t5/revit-api-forum/problem-with-constraining-stirrups-to-the-cover-of-th...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes