Get Project Parameters , Parameter Data (name,disc, type, group) and categories they belong to, to export in excel

I’m trying to get Project Parameters Data (name,disc, type, group) and categories they belong to, but stuck almost from the start
I can get Project needed parameters and their id but I can`t find a way do get their Data (name,disc, type, group) and categories they belong to.


Any help appreciated!

Do you mean like this?

You may have to look at the Clockwork nodes for project parameters and adjust the python code to get what you want. Or there may be other packages with nodes to help you.

1 Like

No, sorry maybe I provide not too much information in the start of the topic.
I’m looking project parameters that are in the manage tab like below
image

Thanks Nick I have seen the document.projectparameters node if you mean this node. Actually I cant understand how ho get from this node that I need. I can see the list of all parameters.. types .. but I cant get parameters I need. No pythin coding skills as well

I’m afraid it’s going to take python to get what you’re after. You might get lucky and find some custom nodes from someone who has already tackled this issue, or you may have to look into python yourself.

Slightly off topic Nick but I’ve started learning Python. You were definitely an influence in that. :slight_smile:

1 Like

Hello
a Python solution using ParameterBindings

# coding : utf-8
import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument


class ParaProj():
	def __init__(self, definition, binding):
		self.defName = definition.Name
		self.binding = binding 
		self.thesecats = []
		self.group = LabelUtils.GetLabelFor(definition.ParameterGroup)
		self.type = "Instance" if isinstance(binding, InstanceBinding) else "Type"
		
	@property	
	def categories(self):
		thesecats = []	
		for cat in self.binding.Categories:
	 		try:
				thesecats.append(cat.Name)
			except SystemError:
				pass  
		return thesecats
		
	@property					
	def isShared(self):
		collSharP = FilteredElementCollector(doc).OfClass(SharedParameterElement)
		paraSharPara = [x.GetDefinition().Name for x in collSharP]	
		return 	True if self.defName in paraSharPara else False	
				

paraName = []
paraGroup = []
paraCategories = [] 
paraType = []
paraIsShared = []
iterator =  doc.ParameterBindings.ForwardIterator()
while iterator.MoveNext():
    objBind = ParaProj(iterator.Key, iterator.Current)
    paraName.append(objBind.defName)
    paraGroup.append(objBind.group)
    paraType.append(objBind.type)
    paraIsShared.append(objBind.isShared)
    paraCategories.append(objBind.categories)
  

OUT = paraName, paraGroup, paraType, paraIsShared, paraCategories

another example here (at the bottom of my article) with a TreeNode (WinForm)

7 Likes

Hi @c.poupin,
I tested your great code to list the project parameters, and:

  1. I need to filter out only the shared parameters loaded from the .txt file (and not others shared parameters came from inside loaded family into the project) but I don’t know how
  2. what does it mean the read color?

    Thank you
    Have a good day

Hello @paris

you can get all definitions name from your Shared Parameter File and compare them with each definition Name in BindingMap (or using guid)

method with Name

lstExtDef_Name = []
spf = app.OpenSharedParameterFile()
if spf is not None:
	spfGroups = spf.Groups
	for group in spfGroups:
		for def_ in group.Definitions:
			lstExtDef_Name.append(def_.Name)
			
	iterator =  doc.ParameterBindings.ForwardIterator()
	while iterator.MoveNext():
		if iterator.Key.Name in lstExtDef_Name:
			#processing 
			#....

method with guid

full_bind = []
spf = app.OpenSharedParameterFile()
if spf is not None:
	spfGroups = spf.Groups
	for group in spfGroups:
		for def_ in group.Definitions:
			sharInProject = SharedParameterElement.Lookup(doc, def_.GUID)
			if sharInProject is not None:
				binding_map = doc.ParameterBindings
				binding = binding_map.Item[sharInProject.GetDefinition()]
				if binding is not None:
					#rest of code
					#objBind = ...
					#full_bind.append(objBind)

Blue for Instance Parameter
Red for Type Parameter

3 Likes

Hi @c.poupin , great, very impressive, you are amazing! I’ll try it with the projects of the custumer where I have the txt files of shared parameters, but is there another workaround for others projects where there is no more the .txt file of shared parameters ?
Thank you very much for your help.
Have a good day
Cheers

I do not think so

1 Like

Hi @c.poupin many thanks for your answers and for the great help about the different solutions.
Have a good day.
Cheers

1 Like

that is pretty cool, the plugin as well. In my case I want to know more than just project parameters added into the project, what about the builti-in parameters, is possible to query them in similar way without having to select a bunch of different elements of categories to query the parameters?

I have been asking those annoying questions in some posts recently:

You can try a ‘brute force method’

import clr

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

mydicInstanceParameter = {}
set_elemTypeId = set()
fecElement = FilteredElementCollector(doc).WhereElementIsNotElementType()
for elem in fecElement:
	set_elemTypeId.add(elem.GetTypeId())
	for p in elem.Parameters:
		if p.Definition is not None and elem.Category is not None:
			if p.Definition.Name not in mydicInstanceParameter:
				mydicInstanceParameter[p.Definition.Name] = set([elem.Category.Name])
			else:
				mydicInstanceParameter[p.Definition.Name].add(elem.Category.Name)

mydicTypeParameter = {}
fectypeElement = [doc.GetElement(xId) for xId in set_elemTypeId if doc.GetElement(xId) is not None]
for elem in fectypeElement:
	for p in elem.Parameters:
		if p.Definition is not None and elem.Category is not None:
			if p.Definition.Name not in mydicTypeParameter:
				mydicTypeParameter[p.Definition.Name] = set([elem.Category.Name])
			else:
				mydicTypeParameter[p.Definition.Name].add(elem.Category.Name)
		
OUT = mydicInstanceParameter , mydicTypeParameter

image

thank you to avoid digging up several successive topics in the future, it is better to make a single post and relaunch this one if necessary :wink:

5 Likes

I would like to get a list of the parameters referred as well, amazing script by the way, I guess it is taking in consideration only the elements on current project file

Hi c.poupin & Gavin. Just checking this code to get parameter’s properties. I have a little question: which is the input IN[0] o the Python script node of the image? I’ve tried the current document, a list of elements… thank you so much

Hello there is no input, (in the image it’s a boolean node)