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.