Revit 2017 Categories

Revit 2017 Categories

stephen_harrison
Advocate Advocate
788 Views
2 Replies
Message 1 of 3

Revit 2017 Categories

stephen_harrison
Advocate
Advocate

In Revit 2016 I have used the following code segment to filter the elements and then use an if statement to identify those elements which are bound to a particular Category. This has then allowed me to find the element.id to which the specific shared parameters is bound.

 

catName represents the Name of the Category to which the Shared Parameter is bound

This Shared Parameter data is then stored in a list.

 

FilteredElementCollector elementCollector = new FilteredElementCollector(doc);
ElementIsElementTypeFilter elementTypeFilter = new ElementIsElementTypeFilter(true);
elementCollector.WherePasses((ElementFilter)elementTypeFilter);
IEnumerator enumerator = (IEnumerator)elementCollector.GetElementIterator();
while (enumerator.MoveNext())
                {
                    Element element = (Element)enumerator.Current;
                    if (!(element is ElementType) && element.Category != null && element.Category.Name == catName)
                    {
                        //Create list of parameters by name this is in case there are more than one with the same name
                        IList<Parameter> parameters = element.GetParameters(spName);
                        foreach (Parameter parameter in parameters)
                        {
                            if (parameter.IsShared && parameter.Definition.Name == spName && parameter.GUID == spGuid)
                            {
                                string pValue = ParameterValue(parameter);
                                ExistingSharedParamInfoList.Add(new ExistingSharedParam()
                                {
                                    GUID = parameter.GUID.ToString(),
                                    Name = parameter.Definition.Name,
                                    DataType = parameter.Definition.ParameterType,
                                    Modifiable = parameter.UserModifiable,
                                    CatGroup = element.Category.Name.ToString(),
                                    ElemID = element.Id,
                                    ParamGroup = parameter.Definition.ParameterGroup,
                                    ParamValue = pValue,
                                    ParamBinding = spBindingType,
                                });
                            }
                        }
                    }

However, since the 2017 release there are a number of new Categories to which Shared Parameters can be bound

 

For Type Parameters these are:


Multi-segmented Grid
MEP Fabrication Containment
MEP Fabrication Ductwork
MEP Fabrication Hangers
MEP Fabrication Pipework
      Fabric Wire
Structural Rebar Coupler

 

For Instance Parameters these are:


Multi-segmented Grid
MEP Fabrication Containment
MEP Fabrication Ductwork
      Insulation
      Lining

MEP Fabrication Hangers
MEP Fabrication Pipework
      Insulation
      Fabric Wire
Structural Rebar Couplers

 

My problem is that the above filter appears to no longer works and I have no way of identifying the elements to which this Shared Parameter is bound. Your assistance would be much appreciated, as would a code segment to point me in the right direction.

 

0 Likes
Accepted solutions (1)
789 Views
2 Replies
Replies (2)
Message 2 of 3

matthew_taylor
Advisor
Advisor
Hi Stephen,
I kinda get what you're saying, but some clarification is necessary.
Are you trying to get elements that have a shared parameter applied (either by a family definition shared parameter, or by a project shared parameter applied to that element's category)?
Dealing with parameters and categories by name instead of by builtin parameters, guids, or builtin categories may be clouding the issue.
Can you clarify what you're trying to achieve so I can help with what you're trying to do, not what *I* think you're trying to do?

-Matt

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 3 of 3

stephen_harrison
Advocate
Advocate
Accepted solution

Matt
Thank you for your response and apologies for not responding sooner.


Yes, the aim of the code was to get elements that have a shared parameter applied to that element category.
Having had a few days away from a computer I have had time to reflect on the problem and realised that even though you can add shared parameters to a project that does not necessarily mean there are any elements for that category present in the project.

 

For example, add a shared parameter to Category, Door and if there are no doors in the project/project browser then the filter will not find the element and consequentially the shared parameter.

 

Once again thank you for your response.

0 Likes