Attribute Error on Archi Lab Node

I am trying to change utilize the “Set BuiltIn Parameter” Node from Archi-Lab in Revit 2023

This is the python script inside of the code block.


# Copyright(c) 2019, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

import clr
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

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

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

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

paramName = IN[0]

if not isinstance(IN[1], list):
        elements = [IN[1]]
else:
        elements = IN[1]

if not isinstance(IN[2], list):
        paramValues = [IN[2]]
else:
        paramValues = IN[2]

def GetBuiltInParam(paramName):
        builtInParams = System.Enum.GetValues(BuiltInParameter)
        test = []
        for i in builtInParams:
                if i.ToString() == paramName:
                        test.append(i)
                        break
                else:
                        continue
        return test[0]

try:
        errorReport = None
        TransactionManager.Instance.EnsureInTransaction(doc)
        
        bipName = GetBuiltInParam(paramName)
        for i, j in zip(elements, paramValues):
                param = UnwrapElement(i).get_Parameter(bipName)
                if param.StorageType == StorageType.ElementId:
                        id = ElementId(j)
                        param.Set(id)
                else:
                        param.Set(j)
        
        TransactionManager.Instance.TransactionTaskDone()
except:
        import traceback
        errorReport = traceback.format_exc()

if errorReport == None:
        OUT = IN[1]
else:
        OUT = errorReport

When I run the script, the error it get is;
Traceback (most recent call last):
File"“, line 51, in
File”", line 40, in GetBuiltInParam
Attribute Error: ‘int’ object has no attribute ‘ToString’

I have spent a great deal of time searching attribute errors and anything else it could be, I am completely out of ideas. Could someone please help me?

Thanks!

are you sure the parameter you have plugged in is a built in parameter? BuiltInParameter Enumeration (revitapidocs.com)

if its not in the list there the script will stop at that line which is what seams to be happening.

or the value there is null or emepty

Yes I am sure, I am using VIEWPORT_DETAIL_NUMBER, is there a reason this one would not work while looking at a sheet of details, does the detail have to be active?

hi @markb43

It’s a Python.Net issue, read this

in particular

1 Like

Thank you! That fixed part the issue, but now created a new one. Now I have an error that reads

File “<string”>, line 65, in
TypeError: No method matches given argument for get_Parameter: (<class ‘str’>)

According to the article you provided this is something that should have been fixed?

Try directly with the BuiltInParameter

example

TransactionManager.Instance.EnsureInTransaction(doc)

for i, j in zip(elements, paramValues):
    param = UnwrapElement(i).get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER)
    param.Set(j)

TransactionManager.Instance.TransactionTaskDone()