Hi everyone, I am trying to get element from Item number of that equipment. In my case, “Item Number” is a shared parameter of instance type. I am facing the below shown error while executing the code.
The parameter value can be seen in Element.Parameter which is of storage type “string” but still it is unable to fetch the element and rather getting some NoneType object.
Interestingly, the same code is working perfectly in Revit sample project with the same parameters. I could not figure out the reason of it failing in my live project.
This is not a data storage error, the error means that for one or more elements has no “Item Number” parameter
I made schedule of specialty equipment in Revit, deleted the items having no values and some whose Item Number was greyed out and run the script. Still the error persists.
Can we somehow bypass those items by making changes in below code ?
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from Autodesk.DesignScript.Geometry import *
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
elements = IN
Item_Number = IN
#parameter = IN
outList = 
for i in UnwrapElement(elements):
if i.LookupParameter("Item Number").AsString() == IN:
OUT = outList
@shujath36 append the
LookupParameter("Item Number") to the output list, check what is the value of the greyed out ones, filter them out according to the value you got, basically, you should end up with clean elements ready to be filtered out according to the “IN” value:
Thanks for that valuable input. Now I don’t have to bother about those equipment which does not have parameter added in it or having null values.
Another method you can put in there is a try/except clause
This makes it so it tries to do it, then if it doesn’t exist skips to the next element.