Forms.select_parameters with parts

Hi,

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.

Love to hear your 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?

Ill add it on Github

ok. I could need some help on creating the Pull Request. @sanzoghenzo
Do I have to fork it myself first?

K. I hope I did everything correctly. If not: feel free to educate me, I’m all ears!

I’ve forked the master
Editted the file in my fork.
create a pull request for it.

I cannot see your work.
You need to create a PR against the develop-4 branch on the main repo

ah, I created it on the main.

Let me try and branch it against develop-4. So I have to fork develop-4 first right? @Jean-Marc

This is what I have … so I probably did it wrong

Should I Create pull request like this?

Yess!! :wink:
Welcome to the github world!

Im not sure I did it correctly. :frowning:

  1. fork
  2. create new branch from the develop-4 branch in your fork
  3. make your changes in this branch
  4. commit the changes
  5. make a PR from your new branch against the develop-4 branch

I will validate the PR from there.

Awesome, I believe I did it correctly then :slight_smile:

new installers will be available in a bit here Merge pull request #2135 from 3Pinter/3Pinter-patch-forms-init · eirannejad/pyRevit@45afa37 · GitHub

Thanks @jvandermeulen