Chagetypeid() not working in CPython

Hi,

I’m trying to write up a python code where I can change element type(wall, stairs, etc.), but I’m having issue with the changetypeid() API because it’s not working in CPython.

I found this issue has been there for a long time but looks like it’s not resolved. (TypeError: No method matches given arguments for · Issue #2850 · DynamoDS/DynamoRevit · GitHub)

Is there a workaround to change type in CPython? The image is showing just a part of a larger script, so I can’t do it with Dynamo nodes. And we need to use Revit 2023 and upper so I can’t use IronPython, and we want to avoid using any package.


I found the same topic here( CPython3 and Element.ChangeTypeId - Revit - Dynamo (dynamobim.com)), but it’s an old post and didn’t see any reply so wanted to bring up again.

Thanks

I don’t see an image or a sample code to reproduce with… did things not upload all the way?

Hi Jacob. Sorry, just uploaded again!

1 Like

Here is the C-Python code for changeTypeId

GPI = NewFamily.GetType().GetMethod("ChangeTypeId")
GPI.Invoke(NewFamily, [ElementId(InGridType.Id)])

succes

Hi, another workaround is to use the static method instead

1 Like

Thank you so much, this worked like a charm!