PyhtonScript Project Information

Need Help, whats wrong with this?
I’ve debugged in Visual Studio Code but only complain of row 1 “Import clr”

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_byggnadsID_param = i.LookupParameter(‘RKL_ByggnadsID’)
project_fastighetsID_param = i.LookupParameter(‘RKL_FastighetsID’)

if project_byggnadsID_param != “” and project_fastighetsID_param !=“”:
OUT.Add(False)
elif project_byggnadsID_param.startswith(“8”) and project_fastighetsID_param.startswith(“F8”):
OUT.Add(True)
else:
OUT.Add(False)

The general approach is valid:
image

But if you are pasting code here use the tool for preformated text:
image

3 Likes

Thanks for that, i’ve updated my post.

So you mean that my script should work?

I believe you may also want to get the value of the parameter given you are comparing it to a string. Try using the method .AsValueString() after the parameter object to get its value before checking it at the end.

3 Likes

as @GavinCrump said it seems that you’re comparing the parameter object to a string where you would need to compare the parameter value. Use .AsString() for text parameters (I assume the building and apartment ids are texts?) or .AsValueString() to get the UI representation of number integer and ElementId parameters.
Also the quotation marks in your code look a bit different than standard. I had that problem when I accidentally used quotation marks from the cyrillic alphabet so you might want to check on that too.
And, of course, read the error message the Python node is giving you. It helps a lot

2 Likes