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
I think clockwork package has already node called “Document.ProjectParameters” it will retrieve all project parameters and the categories they are assigned to.
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)