Need help with Project Parameters

Hello everyone,
I am quite new to Pyrevit. I have worked prevously with elements in PyRevit, however not with parameters. I need to associate many types of project parameters with Revit elements automatically as there are many elements and parameters. I have prepared a excel file for this. The format of excel file is-
Picture1

The first row contains object name and first column contains parameter name. Respective cells are marked with “X” if the parameter should belong to the element.

I would like to build a tool whose primary objective will be as follows:

  • Import Parameter data from Excel and create project parameters in revit.
  • Add project parameters to respective elements/objects as per the names in the excel file.

Thanks in advance for the help!!!

Welcome,

Well, pyRevit is not always the one stop solution. While possible, in your specific case, I would not ‘waste’ time trying to build a tool, but I would rather use DiRoots paramanager that will let you do exactly what you have in mind, and for free.

This!

And if you have to start with the matrix you described, just write a script to read the excel and transform it into the diroots paramanager excel format. That’s what I did for my firm, I’ll post some more info as soon as I get to my desk :wink:

One limitation with this setup, though: you can’t do any batch processing, so you have to open the models one by one to run diroots. This is a request from my colleagues that I still have to fulfill because I don’t want to rewrite paramanager in python :rofl: it would be wonderful if we could access paramanager apis from pyrevit…

OK, first I used an excel formula to get all the objects names for a parameter in a single cell:

=TEXTJOIN(", ",TRUE,IF("X"=<range of matrix row>,<range of headers>,""))

In the excel file there are other info needed to define the parameter: the value type, if it is an instance or type parameter, and so on.

The script reads our excel, extracts the needed info, then opens the paramanager excel and adds/removes/edits the parameters following the needed structure.

There’s one catch: the libraries shipped with pyRevit to read and write excel files cannot edit an existing file (the paramanager export), so I needed to switch to a Cpython script and create the openpyxl lib extension.

Thank you so much for your reply, will start working on this now :wink: