I noticed that the forms.select_parameters breaks when the input is ‘wrong’.
I had a selection of some elements and one of them was a DB.Part and Part has no Type thus no type parameters.
So on line 2685 of init.py src_type = revit.query.get_type(src_element)
will return None on elements with no Type properties.
Unsure if this is expected behaviour.
Forms.select_parameters Case 1:
only parts are selected: we can exclude type properties using include_type = False.
Forms.select_parameters Case 2:
a mix of elements are used and we would like to filter on instance and type properties (and accepting that some don’t have type properties): error.
For now I’ve fixed this (yup, I’m a case 2 guy) using a check if src_type isn’t None.
if include_type:
# collect type parameters
src_type = revit.query.get_type(src_element)
if src_type is not None:
param_defs.extend(
[ParamDef(name=x.Definition.Name,
istype=True,
definition=x.Definition,
isreadonly=x.IsReadOnly)
for x in src_type.Parameters
if x.StorageType != non_storage_type]
)
Again, unsure if the behaviour is as excepted, perhaps food for thoughts.
Hi @jvandermeulen,
thanks for the report, I think you’re right! the get_type function calls the element GetTypeId method; stating the Revit API reference:
Some elements cannot have type assigned, in which case this method returns invalid element id.
So I definitely support your fix!
Are you comfortable with git to create a PR to fix the code yourself?
If not, would you like to have some assistance to get your hands dirty, or do you prefer to wait for us to do the work?