Rebar placement for Generic Model.

Rebar placement for Generic Model.

shindeaa15
Contributor Contributor
570 Views
4 Replies
Message 1 of 5

Rebar placement for Generic Model.

shindeaa15
Contributor
Contributor

Query: I am trying to place rebars for Generic Model, while placement I am facing below error. Can anyone please guide?

 

Error:  "host is not a valid rebar host.\r\n Parameter name: host"

shindeaa15_0-1722585019378.png

 

Code: 

using (var txx = new Transaction(doc, "Distribution Bar for Wall"))
            {
                txx.Start();
                XYZ lst1 = new XYZ(lineSt.X - 1.0, lineSt.Y - 1.0, lineSt.Z - 2.0);
                XYZ est1 = new XYZ(lineEn.X - 1.0, lineEn.Y - 1.0, lineEn.Z + 2.0);
 
                double rebarQty = 10;
                double spacing = 0.5;
 
                List<RebarBarType> coll = new FilteredElementCollector(doc).OfClass(typeof(RebarBarType)).WhereElementIsElementType().Cast<RebarBarType>().ToList();
                RebarBarType barType = coll.First(x => x.Name == "D10"); //"D25 主筋2"
 
                double cover = 0.25;
 
 
                for (int i = 0; i < rebarQty; i++)
                {
                    XYZ lst = new XYZ(lineSt.X - spacing, lineSt.Y - 1.0, lineSt.Z - 2.0);
                    XYZ est = new XYZ(lineEn.X - spacing, lineEn.Y - 1.0, lineEn.Z + 2.0);
 
                    List<Curve> distBarCurve = new List<Curve> { Line.CreateBound(lst, est) as Curve };
 
                    Rebar distBars = Rebar.CreateFromCurves(doc, RebarStyle.Standard, barType, null, null, oEle, newNormal, distBarCurve, RebarHookOrientation.Left, RebarHookOrientation.Right, true, true);
 
                    distBars.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(1, cover, true, true, true);
 
                    spacing += 0.5;
                }
 
                txx.Commit();
            }
 
 
 
Note: Here I am passing below element as host.
Reference selectEntity = uiDoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Select a Haunch");
Element oEle= document.GetElement(selectEntity);
0 Likes
571 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

Can you place rebar in that host manually using the end user interface? If no, it will not be possible programmatically either.

   

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

shindeaa15
Contributor
Contributor

I have tried to place rebars manually, but unable to select the Host. Please find the attached model.

Please Let me know if different steps needs to be followed to achieve Rebar placement for attached model.

 

Thank you in advance for addressing issue.

0 Likes
Message 4 of 5

jeremy_tammik
Alumni
Alumni

Please solve this issue manually in the end user interface first, before starting to think about an API solution. The API will not enable anything that the UI cannot. The best place to discuss it might be in the structural forum.

   

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

shindeaa15
Contributor
Contributor

Okay

Thank you...

0 Likes