Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ChangeTypeId not working for StairsPaths in Revit 2022

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
g_sicre
501 Views, 5 Replies

ChangeTypeId not working for StairsPaths in Revit 2022

Hello folks,

 

I developed a code to place stairs paths in stairs that is working fine in Revit versions 2020 & 20221. Nevertheless, when testing it in Revit 2022 it gives me the following error:

 

"Warning: TypeError : No method matches given arguments for ChangeTypeId: (<class 'Autodesk.Revit.DB.Architecture.StairsPath'>, <class 'Autodesk.Revit.DB.ElementId'>) [' File "<string>", line 24, in <module>\n']"

 

The method exists for Revit API 2022.

 

Please, find attached a simplifed version of the code.

 

Any comments will be appreciated, thanks.

g_sicre_0-1672918180928.jpeg

 

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

doc = DocumentManager.Instance.CurrentDBDocument

# ------------------------------------------------------------------------------------------------------------------- # CODE

stairsPath = UnwrapElement(IN[0])
pathId = FilteredElementCollector(doc).OfClass(StairsPathType).FirstElementId()

TransactionManager.Instance.ForceCloseTransaction()
t = Transaction(doc, 'Test')
t.Start()

stairsPath.ChangeTypeId(pathId)

t.Commit()
OUT = None

Labels (3)
5 REPLIES 5
Message 2 of 6
g_sicre
in reply to: g_sicre

(Just editing this reply due to an previous error)

Message 3 of 6
architect.bim
in reply to: g_sicre

Actually this method works fine in Revit 2022 too. I've just checked it using Revit Python Shell. Try to open Transaction in a bit different way, may be that helps. If not there must be some inaccurancy in your code, because the method you use if fine:

s_path_type_id = FEC(doc).OfClass(StairsPathType).FirstElementId()
with DB.Transaction(doc, 'Set Stair Path Type') as t:
    t.Start()
    s_path.ChangeTypeId(s_path_type_id)
    t.Commit()

Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 4 of 6
architect.bim
in reply to: g_sicre

Actually, in Dynamo this works fine too. Check the full code and Dynamo script.

architectbim_0-1672920879108.jpeg

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

clr.AddReference('RevitAPI')
from Autodesk.Revit import DB
from Autodesk.Revit.DB.Architecture import StairsPathType
from Autodesk.Revit.DB import FilteredElementCollector as FEC

doc = DocumentManager.Instance.CurrentDBDocument

s_path = UnwrapElement(IN[0])
s_path_type_id = FEC(doc).OfClass(StairsPathType).FirstElementId()
with DB.Transaction(doc, 'Set Stair Path Type') as t:
    t.Start()
    s_path.ChangeTypeId(s_path_type_id)
    t.Commit()

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 5 of 6
g_sicre
in reply to: architect.bim

Hi @architect.bim, thanks so much for testing it.

 

You're right, it's working when using IronPython2 as Python engine. Nevertheless, when swiching the engine to CPython3 it fails.

 

g_sicre_0-1672922010492.png

 

I would like to know why it's failing for future Revit versions.

 

Message 6 of 6
architect.bim
in reply to: g_sicre

As this article says there are many reported issues with this version of Python in Dynamo. You are still able to use IronPython in Revit 2022 and the following versions (in R2023 you need to install additional Dynamo package to use IronPython2). I suggest you should use IronPython as right now it is much more stable.


Maxim Stepannikov | Architect, BIM Manager, Instructor

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community