Rebar Cover Types collector

Rebar Cover Types collector

Anonymous
Not applicable
2,580 Views
10 Replies
Message 1 of 11

Rebar Cover Types collector

Anonymous
Not applicable

Hi All, 

 

I'm trying to collect all of the RebarCoverTypes in my project:

 

image.png

 

I'm using this:

 

FilteredElementCollector rebarCoverCol = new FilteredElementCollector(
rebarCoverCol.OfCategory(BuiltInCategory.OST_RebarCover);

but I'm not getting any elements.

 

In the other hand, previously I made a similar collection using Python in Dynamo, and I got the list of the RebarCoverTypes I wanted to work with.

 

image.png

 

What am I missing here?

 

Thanks in advance!

 

 

0 Likes
Accepted solutions (1)
2,581 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

UPDATE: I managed to rather create a new RebarCoverType to just set this as the rebar cover parameter for the walls.

 

 

// Wall Collector
FilteredElementCollector wallCol = new FilteredElementCollector(doc);            
wallCol.OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType(); // Creating the RCT RebarCoverType rct = RebarCoverType.Create(doc, "CoverName", 2.5 / 30.48); // assignment
foreach (Wall w in wallCol) { if (w.LookupParameter("Structural").AsValueString() == "Yes") { w.LookupParameter("Rebar Cover - Exterior Face").Set(rct.Id); w.LookupParameter("Rebar Cover - Interior Face").Set(rct.Id); w.LookupParameter("Rebar Cover - Other Faces").Set(rct.Id); } else { counter+= 1; } }

Now, the problem is that it says that this parameter is read-only. This is weird because using Dynamo I manage to do this with no problem.

 

What am I missing now?

 

Thanks in advance!

 

0 Likes
Message 3 of 11

jeremytammik
Autodesk
Autodesk

It sounds as if you need some deeper insight into the database contents and API interaction, plus you know Python.

 

Check out this description that might help:

 

http://thebuildingcoder.typepad.com/blog/2013/11/intimate-revit-database-exploration-with-the-python...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 11

Anonymous
Not applicable

Dear Jeremy, 

 

Thanks for the info provided. I read the document mentioned and with the help of Revit Lookup I dig into the BuiltInParameter I needed.

 

Here I have 2 questions:

 

1.- I changed my code to this, but I'm still getting the warning saying it is a "read-only" parameter. (I still can't figure it out why through this procedure I can't set a different value and with Dynamo's procedure I can.)

 

 

// se asignan los rebar cover
                foreach (Wall w in wallCol)
                {
                    if (w.LookupParameter("Structural").AsValueString() == "Yes")
                    {
                        w.get_Parameter(BuiltInParameter.CLEAR_COVER_EXTERIOR).Set(rct.Id);
                        w.get_Parameter(BuiltInParameter.CLEAR_COVER_INTERIOR).Set(rct.Id);
                        w.get_Parameter(BuiltInParameter.CLEAR_COVER_OTHER).Set(rct.Id);
                    }
                    else
                    {
                        contador += 1;
                    }
                }

 

image.png

 

 

2.- Another thing I can't figure is how to create a collection of BuiltinParameters. My efforts drove me this:

 

FilteredElementCollector rctCol = new FilteredElementCollector(doc);            
rctCol.OfClass(typeof(Parameter(BuiltInParameter)));

Thanks in advance!

 

0 Likes
Message 5 of 11

jeremytammik
Autodesk
Autodesk

Here is a collection of built-in parameters for you:

 

    BuiltInParameter[] bips = new BuiltInParameter[] {
      BuiltInParameter.ACTUAL_MAX_RIDGE_HEIGHT_PARAM,
      BuiltInParameter.ALLOW_AUTO_EMBED,
      BuiltInParameter.ALL_GRID_ROTATION_FOR_DIVISION_RULE
      // ...
    };

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 11

so-chong
Advocate
Advocate
Accepted solution

hi, i have tested your code in sharpdevelop (macro) and everything went successfully.

are you using Visual Studio as an external command?

can you show your code completely?

 

     public void ModifyRebarCoverWalls()
    {
        UIDocument uidoc = this.ActiveUIDocument;
        Document doc = uidoc.Document;
        // Wall Collector
        FilteredElementCollector wallCol = new FilteredElementCollector(doc);            
        wallCol.OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType();
        
        using (Transaction t = new Transaction(doc, "Adjust Wall Rebar Cover"))
        {
            t.Start();
        
            // Creating the RCT
            RebarCoverType rct = RebarCoverType.Create(doc, "CoverName"3.0 / 30.48);
            int counter = 0;
            // assignment
            foreach (Wall w in wallCol)
            {
                if (w.LookupParameter("Structural").AsValueString() == "Yes")
                {
                    w.LookupParameter("Rebar Cover - Exterior Face").Set(rct.Id);
                    w.LookupParameter("Rebar Cover - Interior Face").Set(rct.Id);
                    w.LookupParameter("Rebar Cover - Other Faces").Set(rct.Id);
                }
                else
                {
                    counter+= 1;
                }
            }
            t.Commit();
        }
    }

 

rebar-cover.png

Message 7 of 11

RPTHOMAS108
Mentor
Mentor

Also worth noting that there is a specific class in the structure namespace set up for these tasks i.e.

 

RebarHostData.GetRebarHostData

 

then

 

RebarHostData.SetCoverType

or

RebarHostData.SetCommonCoverType

Message 8 of 11

so-chong
Advocate
Advocate

hi, you can try do something like this.

 

hope this helps, and good luck.

 

cheers,

 

so-chong

 

public void RebarCoverInfo()
{            
    Document doc = this.ActiveUIDocument.Document;
    List<Element> rebarcovers = new FilteredElementCollector(doc).OfClass(typeof(RebarCoverType)).ToList();
    double ftMM = 304.8;
    string rebarInfo = "";
    string rebarName = "";
    foreach (Element rebarcover in rebarcovers)
    {
        RebarCoverType rt = rebarcover as RebarCoverType;                
        rebarName = rebarcover.Name + " --- " + (rt.CoverDistance * ftMM).ToString() + "mm";
        rebarInfo += rebarName + Environment.NewLine;                
    }
    TaskDialog.Show("Rebar Cover Info",rebarInfo.ToString());
}

rebar-cover-info.png

Message 9 of 11

Anonymous
Not applicable

Please tell me, how to add one more item to this list? In the code.

 

 

Thank You 

 

saw a solution

0 Likes
Message 10 of 11

so-chong
Advocate
Advocate

hi, you have to use the Create() method to add a Rebar Cover type.

something like this macro

 

 

     public void CreateRebarCoverType()
     {
         UIDocument uidoc = this.ActiveUIDocument;
         Document doc = uidoc.Document;
         
         using (Transaction t = new Transaction(doc, "Create Rebar Cover 3"))
         {
             t.Start();
         
             // Creating the RCT
             RebarCoverType rct = RebarCoverType.Create(doc, "Rebar Cover 3"8.0 / 30.48);

             t.Commit();
         }
     }

 

Message 11 of 11

Anonymous
Not applicable

Hi @so-chong sorry for the late reply but just now I came back to finish this. I used your parameter assignation way (with "LookUpParameter()") and some other customization and it worked just fine!.

 

Here is what I did. Hope It will help someone else.

 

 

// RebarCoverTypes Collector
            FilteredElementCollector rctCol =
                new FilteredElementCollector(doc)
                .OfClass(typeof(RebarCoverType))
                .WhereElementIsElementType();

// If it not created, create a new RebarCoverType

                List<string> rctName = new List<string>();

                foreach(Element e in rctCol)
                {
                    RebarCoverType rctExistente = e as RebarCoverType;
                    rctName.Add(rctExistente.Name);
                }

                RebarCoverType rct = null;

                if (rctName.Contains("CoverName"))
                {
                    foreach(Element e in rctCol)
                    {
                        if(e.Name == "CoverName")
                        {
                            rct = e as RebarCoverType;
                        }
                    }
                }
                else
                {
                    rct = RebarCoverType.Create(doc, "CoverName", 2.5 / 30.48);
                }                

                // RebarCoverType Assignment
                foreach (Wall w in wallCol)
                {
                    if (w.LookupParameter("Structural").AsValueString() == "Yes")
                    {
                        w.LookupParameter("Rebar Cover - Exterior Face").Set(rct.Id);
                        w.LookupParameter("Rebar Cover - Interior Face").Set(rct.Id);
                        w.LookupParameter("Rebar Cover - Other Faces").Set(rct.Id);
                    }
                }

 

 

 

Thanks!