Hi all, I am trying to update a large Python script within Dyanmo from 2.7 to CPython but I cannot get toRoom to work.
I have broken it down to its simplest state. I would appreciate any help that you can provide. I did try the converter button but it said the code was good to go.
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
selection = doc.GetElement(uidoc.Selection.GetElementIds()[0])
phases = [i for i in doc.Phases][::-1]
phase = phases[1]
toRoom = selection.ToRoom[phase]
OUT = selection,phase,toRoom
All three python nodes have the same code with the exception of the middle one where I turned off toRoom just to prove that the door and phase are still being found. (the top node is 2.7).
The API does not have much documentation of this call but here it is ToRoom Property (Phase)
If phase is not important you can use the property familyinstance.ToRoom otherwise use the method familyinstance.get_ToRoom(phase)
With python you can use dir(object) to get a list of properties and methods when trying to get around limitations of the documentation and the pythonnet library
I just guessed the overload familyinstance.get_ToRoom(phase) would work and tested it. The method is listed in the dir function - it’s at the end of the list with all the other get_ and set_ methods on a family instance object
Sorry to question you that was my mistake. When I checked the dir list I did it from IronPython2.7. There are a lot more properties that show up when you check it from cPython.