Project Parameter Id & GUID

Project Parameter Id & GUID

stephen_harrison
Advocate Advocate
5,926 Views
6 Replies
Message 1 of 7

Project Parameter Id & GUID

stephen_harrison
Advocate
Advocate

I am new to programming and even newer to the Revit API however as I understand it parameter data is stored in several places within the Revit database?

By utilising BindingMap I have created a list of Project Parameters unfortunately this does not contain all the related information I require.

 

BindingMap bMap = doc.ParameterBindings;
            DefinitionBindingMapIterator mapIterator = bMap.ForwardIterator();
            mapIterator.Reset();
            string s = "";
            List<string> list = new List<string>();
            while (mapIterator.MoveNext())
            {
                Definition def =null;
                def = mapIterator.Key;
               
                list.Add(def.Name);
                
                ListNumber = list.Count;
            }

 

By creating a collection utilising FilteredElementCollector(doc)WhereElementIsNotElementType I have a much larger list of data that contains all the "project parameters" as well as much more element data, however this collection does contain and the additional data I require (Id and GUID).

 

var collector = new FilteredElementCollector(doc).WhereElementIsNotElementType();
 
//Cycle through all elements in the scene, identify their element ID and GUID.
         foreach (Element elem in collector)
         {
         int elemId = elem.Id.IntegerValue;
         string elemName = elem.Name.ToString();
         Guid elemGuid = Autodesk.Revit.DB.ExportUtils.GetExportId(elem.Document, elem.Id);
         }

Is there any way of utilising the list from the Binding Map to filter or extract the required additional data from the Filtered collection?

Or is there a much simpler method of getting this additional data?

 

Any help would be much appreciated.

 

Product: Revit 2016

Programming Language: C#

0 Likes
Accepted solutions (2)
5,927 Views
6 Replies
Replies (6)
Message 2 of 7

Aaron.Lu
Autodesk
Autodesk
Dear,
Do you want to filter out all the element with a specific "project parameter"?
if yes, then you can get which categories that "project parameter" is bound to, and check whether it is a type bind or instance bind, then use category filter and ElementIsNotElementType() method to filter all of the related elements, those elements should contain the "project parameter" you want.

Hope it helps.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 7

stephen_harrison
Advocate
Advocate

Thank you for your response.

Ultimately what I wish to have is a list of Project Parameters with their ID and GUID (when created from a shared parameter).

The use of BindingMap appears to provide the Project Parameters I am looking for but not the ID and GUID

.

0 Likes
Message 4 of 7

rosalesduquej
Alumni
Alumni

Hi Stephen,

 

Sorry for keeping you wait, Aaron is out of the office until next week, I read your case and I see there has been similar requests in the past in order to obtain the GUID of your parameter. Is Parameter.GUID is the property you seek? 

 

Take a look at this thread https://forums.autodesk.com/t5/revit-api/reporting-on-project-parameter-definitions-need-guids/td-p/...

 

Also Jeremy has posted about this in the past, here is the link, it might help you to get closer to your solution. http://thebuildingcoder.typepad.com/blog/2012/04/adding-a-category-to-a-shared-parameter-binding.htm...

 

Let us know how your investigation goes.

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 5 of 7

Aaron.Lu
Autodesk
Autodesk
Accepted solution
Hi Stephen,

If you are using Revit 2016, you can use ElementClassFilter to filter out all SharedParameterElement, whose Id and GuidValue is what you want.

if you are using Revit 2015, unfortunately you can only get Guid value, here is how:
* Application.OpenSharedParameterFile()
* DefinitionFile.Groups
* DefinitionGroup.Definitions
* ExternalDefinition.GUID

reference link: http://spiderinnet.typepad.com/blog/2011/05/parameter-of-revit-api-24-shared-parameter-information.h...


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 6 of 7

stephen_harrison
Advocate
Advocate
Thank you so much for the guidance on this issue. The use of SharedParameterElement has really helped. The introduction of this in 2016 has made the task far easier.
0 Likes
Message 7 of 7

Aaron.Lu
Autodesk
Autodesk
Accepted solution
you can accept it as the solution, or provide your own if you solved it. so that others can easily find the answer next time.

thanks 😉


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes