Debugging Python Code

Awesome, thanks for helping track the cause.

Keep in mind the use of RPW_GetFilePath is optional and the node does not need to be used at all. It’s just mean to help.

For a custom install location, you can always just use something like:

import sys
rpw_path = r'C:\Users\XXX\AppData\Roaming\Dynamo\Dynamo Revit\1.3\packages\RevitPythonWrapper\extra\rpw.zip'
# Or any location where rpw.zip is stored.
sys.path.append(rpw_path)

import rpw

wt we should do now ?, can u show the graph :joy:

Hi @Gui_Talarico. I tried you debugger with the example described above and it works just fine, but I don’t know how to use it If I’m working with a python node which reads a script from a file (IDE is PyCharm) and it has 14 inputs?

Thanks in advance!

Hi @Jorge_Villarroel
Sorry I missed this msg!
Yes, you can use rpw’s console in pycharm just as you would with an embedded script:

import sys
rpw_path = r"C:\Users\gtalarico\AppData\Roaming\Dynamo\Dynamo Revit\1.2\packages\RevitPythonWrapper\extra\rpw.zip"
# Or any location where rpw.zip is stored. This one ^ was installed with the package manager
# but you can also download it form github
sys.path.append(rpw_path)
OUT = 'Test'
import rpw
from rpw.ui.forms import Console
#
#
for i in range(10):
    if i == 5:
        Console(context=locals())

You can read more about it here:
http://revitpythonwrapper.readthedocs.io/en/latest/forms.html#console

3 Likes

Hey,
Just want to say this tools is enormously useful!!! Thank you @Gui_Talarico !!

1 Like

Heyhey,
thanks for writing this, Gui, as well as your ironpython stubs which I’m using whenever I have Dynamo open.
As for this package - I assume Revit is necessary for this console to work? I’m using Dynamo for Alias, is there a possibility to use some other console or window for output like this?
Thanks in advance,

Johannes

1 Like

Hi @Gui_Talarico, I use Revit 2020.2 & Dynamo 2.3 & RPW 1.7.2 and I get an error when I use the following code in the Python node for testing the RPW. Should it still work with Revit 2020.2 ? any help would be appreciated :slight_smile:

import sys
rpw_path = r’C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip’
sys.path.append(rpw_path)
import rpw
from rpw import revit
doc = revit.doc
OUT = doc

Error Message of the Python Node:

Warnung:IronPythonEvaluator.EvaluateIronPythonScript fehlgeschlagen.
Traceback (most recent call last):
File “”, line 17, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw_init_.py”, line 36, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db_init_.py”, line 19, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\view.py”, line 10, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\collector.py”, line 35, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui_init_.py”, line 1, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms_init_.py”, line 12, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\flexform.py”, line 6, in
File “C:\Users\thomas.vogt\AppData\Roaming\Dynamo\Dynamo Revit\2.3\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\resources.py”, line 41, in
File “C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8\wpf.py”, line 11, in
ImportError: No module named _wpf

2 Likes

@Thomas3 Did you ever resolve this? I’m running into the same issue.

rps opens fine in Revit but i get the same error in dynamo as you have.

UPDATE: i got dynamo to be able to recognize rpw finally by just removing the underscore. you can find more about it here

Now i just need to get pycharm to be able to work with it.

my pycharm error is now this:

C:\Python27\python.exe C:/Users/username/PycharmProjects/pythonProject/test.py
[WARNING] Error Importing CLR. Loading Mock Importer
Traceback (most recent call last):
File “C:/Users/username/PycharmProjects/pythonProject/test.py”, line 13, in
Console(context=locals())
File “C:\Users\username\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\rpw.zip\rpw\ui\forms\console.py”, line 130, in init
AttributeError: ‘Console’ object has no attribute ‘PreviewKeyDown’

Process finished with exit code 1

and then in my dynamo, i’m getting this

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 14, in
File “C:\Users\username\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\rpw.zip\rpw\ui\forms\console.py”, line 128, in init
AttributeError: ‘module’ object has no attribute ‘LoadComponent’

This issue is related to the iron python engine. I got the same kind of issue using pyrevit, I got it fixed changing pyrevit iron python engine.

Hi @Jean-Marc , thanks for the input. I just went through all the different iron python options in my pyrevit and restarted my revit every time but none of them worked. I got the same issue every time.

Any other ideas on how to solve this would be great!

In the image below, the one highlighted in yellow is the original setting if that helps.

This fix works if you run your python code as a pyrevit button. Not if it is a dynamo script as the ironpython engine attached to dynamo cannot be change (but my assumption is above my pay grade :slight_smile: )

FYI I am using rpw module from pyrevit with the 278 engine and it works with my wpf command

Any updates to get it to work in Dynamo for Revit 2022?

1 Like

@Gui_Talarico @cflux
Hi, Could you give some advises
Thanks in advance

警告: IronPythonEvaluator.EvaluateIronPythonScript 作業失敗。
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\__init__.py", line 36, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\__init__.py", line 19, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\view.py", line 10, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\db\collector.py", line 35, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\__init__.py", line 1, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\__init__.py", line 12, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\flexform.py", line 6, in <module>
  File "C:\Users\Tabc\AppData\Roaming\Dynamo\Dynamo Revit\2.6\packages\RevitPythonWrapper\extra\rpw.zip\rpw\ui\forms\resources.py", line 41, in <module>
  File "C:\Program Files\Autodesk\Revit 2021\AddIns\DynamoForRevit\IronPython.StdLib.2.7.9\wpf.py", line 11, in <module>
ImportError: No module named _wpf

image

After I read this post, it works

Perfect!