How to get all parameters of cateogries

How to get all parameters of cateogries

genosyde
Advocate Advocate
3,879 Views
4 Replies
Message 1 of 5

How to get all parameters of cateogries

genosyde
Advocate
Advocate

Hi. Dear developers.
I'm currently making a feature that gets all parameters by category.

For example, CableTray has more than one Families.

genosyde_0-1616630210241.png

 

If you look at the properties of both types, you can see that there is more parameter 'Rung Space' in Ladder Type.

So, if I click on the cable tray item in the category, I want to get all the parameters including'Rung Space'.

For this, I referred to Revit Look in Building Coder. From the link below, I was able to get a list of all parameters and values ​​of the Levit instance object.


https://github.com/jeremytammik/RevitLookup/blob/master/CS/Snoop/CollectorExts/CollectorExtElement.c...

But this is how I get the parameters of the object, not the category parameters I want.

And I found bolow link.

https://forums.autodesk.com/t5/revit-api-forum/get-category-parameters/td-p/6289100

https://forums.autodesk.com/t5/revit-api-forum/list-of-parameters-associated-to-the-category/td-p/81...

https://thebuildingcoder.typepad.com/blog/2012/04/adding-a-category-to-a-shared-parameter-binding.ht...

Of the three links above, the second seems to be correct, but I haven't tested it yet.

Please let me know if you have any good ideas.

Best Regards Jason Kim

 

0 Likes
3,880 Views
4 Replies
Replies (4)
Message 2 of 5

franciscopossetto
Advocate
Advocate

Hey,

 

I have used the methods GetAvailableParameters and GetFiltrableParameterInCommon.

 

Both are mentioned on this link you shared:

https://forums.autodesk.com/t5/revit-api-forum/get-category-parameters/td-p/6289100

 

This is the documentation:

https://www.revitapidocs.com/2020/a97f0bbc-537f-5930-5430-144885dfd39a.htm

https://www.revitapidocs.com/2020/7ea624c7-2c0d-c9bb-3b2c-1ac798cf6606.htm

 

They worked for me. I think whether or not it works for you will depend on what you do next.

What do you need to achieve?  Why do you need to collect parameters by Category?

 

 

Github:
https://github.com/franpossetto
Message 3 of 5

jeremy_tammik
Alumni
Alumni

Before doing anything else, I would suggest exploring the Revit SDK samples and ADN training labs, especially Lab4_2_ExportParametersToExcel in the Revit API training labs with Xtra material:

 

https://github.com/jeremytammik/AdnRevitApiLabsXtra

    

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

genosyde
Advocate
Advocate

Thank you for commenting.

So there's a part that doesn't work well while testing GetFiltrableParameterInCommon.

Can you see my source code, what's wrong?

This is the code to sort out all the categories in the active view of the current drawing

and print out result what parameters are in each category.

Thanks for reading.

            var categories = new FilteredElementCollector(doc, doc.ActiveView.Id)
                .ToElements()
                .Select(x=>x.Category)
                .GroupBy(g=>g.Id)
                .Select(x=>x.Key)
                .ToList()
                ;

            var pids = ParameterFilterUtilities.GetFilterableParametersInCommon(doc, categories);

            foreach (var id in pids)
            {
                ParameterElement pelem = doc.GetElement(id) as ParameterElement;
                Trace.WriteLine($"pName : {pelem}");
            }

 

0 Likes
Message 5 of 5

franciscopossetto
Advocate
Advocate

Hey,

 

You should use only those categories that are filterable. To do that, use the GetAllFiltrableCategories method. It will return a list of Ids that you could use on the GetFiltrableParametersInCommon method. 

 

Since GetFiltrableParametersInCommon returns the common parameters that categories have if you use all the Ids returned by this method, you might get an empty list because it is possible that all those categories have no parameters in common. Even with fewer categories, your result could be also an empty list.

 

I think the best scenario to use this method is the one described in the Remarks:

This set defines the set of parameters that may be used to define a rule on a ParameterFilterElement with a certain set of categories."

 

I used it in that context and was really useful. 

 

I hope it helps,

Kind regards.

Github:
https://github.com/franpossetto
0 Likes