List all parameter data types?

List all parameter data types?

jaySZWNK
Participant Participant
3,496 Views
3 Replies
Message 1 of 4

List all parameter data types?

jaySZWNK
Participant
Participant

Is there a way to list all of the shared parameter data types that are available to Revit as they would appear in the shared parameters file (e.g., HVAC_AIR_FLOW)? To be clear, I am not looking for the parameter data types in a single project or family, but all that are available within Revit.

 

Thank you in advance!

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

matthew_taylor
Advisor
Advisor

Hi @jaySZWNK

Is there a list? I don't know.

Can you make one? Yes:

Create a shared parameter in a shared parameter file for each item in the db.ParameterType enumeration. You'll probably need to put a try-catch around each item as some items in the enumeration may be 'old'.

'get enumeration values
Dim members As System.Array = _
  System.Enum.GetValues(GetType(DB.ParameterType))

This help file link has code that shows you how to create your own shared parameter definition in your shared parameter file. (Approx. the first half of the supplied code.)

 

http://www.revitapidocs.com/2017/7978cb57-0a48-489e-2c8f-116fa2561437.htm

 

You may find the GetLabelFor parameterType overload useful also (to keep track of what's what):

http://www.revitapidocs.com/2017/11b3e9c9-931b-710e-8590-04f4bad86e45.htm


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?
Message 3 of 4

jaySZWNK
Participant
Participant

Thanks for the guidance. I will give this a shot!

0 Likes
Message 4 of 4

JimJia
Alumni
Alumni

Dear jaySZWNK,

 

Please accept our sincerer apology for the delay! We had a backlog in the queue. 
 
If you want to get all shared parameter data types, you need to create it manually.
 
Hope following codes can help you:
private List<ParameterType> getAllSharedParameters(Application app, Document doc)
        {
            List<ParameterType> ret = new List<ParameterType>();

            string filename = app.SharedParametersFilename;
            if (!string.IsNullOrEmpty(filename))
            {
                // get the current shared params file object:
                DefinitionFile file = app.OpenSharedParameterFile();

                if (null != file)
                {
                    foreach (var gp in file.Groups)
                    {
                        foreach (var d in gp.Definitions)
                        {
                            ret.Add(d.ParameterType);
                        }
                    }
                }
            }

            return ret;
        }
 
 

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes