How to retrieve project information parameters?

Hi All,

I’m trying to get a value from a Project parameter but I don’t quite understand how to do it. If some could give me some directions, I’ll appreciate it.

import clr

clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry
from Autodesk.DesignScript.Geometry import *

clr.AddReference('DSCoreNodes')
from DSCore import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

#The inputs to this node will be stored as a list in the IN variables.
input = IN[0]

doc = DocumentManager.Instance.CurrentDBDocument

ProyInfo = UnwrapElement(doc.ProjectInformation)

ruta = ProyInfo.GetParameterValueByName("Parameter Name")

#Assign your output to the OUT variable.
OUT = ruta 

Thanks in advance!

1 Like

Hi @Jorge_Villarroel

I think clockwork package has already node called “Document.ProjectParameters” it will retrieve all project parameters and the categories they are assigned to.

And also Document.ProjectInfo node.

Hi Jorge,
maybe this can help you:

import clr

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

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

doc = DocumentManager.Instance.CurrentDBDocument

OUT = []

project_info_collector = FilteredElementCollector(doc) \
                        .OfCategory(BuiltInCategory.OST_ProjectInformation) \
                        .ToElements()

for i in project_info_collector:
	project_name_param = i.LookupParameter('Project Name')
	if project_name_param:
		project_name = project_name_param.AsString()
		OUT.Add(project_name)
	
	project_number_param = i.LookupParameter('Project Number')
	if project_number_param:
		project_number = project_number_param.AsString()
		OUT.Add(project_number)
	else:
		OUT.Add("Perameter not found")

You should first collect the built-in category OST_ProjectInformation and then look for the certain parameter (in this case Project Name and Project Number)

Cheers, Milorad

8 Likes

Thanks @Milorad_Lazicic. I’ll give it a try!

You can just do
doc = DocumentManager.Instance.CurrentDBDocument

projectInfo = doc.ProjectInformation

projectName = projectInfo.Name
ProjectNumber = projectInfo.Number

2 Likes

i am trying to adjust the code so i get all the parameters available in project information… but i keep hitting a errror…

1 Like

image

Clockwork has the solution to your problem :slight_smile:

1 Like


This should be enough if you use pure Dynamo.

3 Likes

Change .Add for .append and it should work