Debugging Python Code

Made a shinny new development toy, I though it might be useful to a few of you;
allows you to launch an interactive console from a breakpoint anywhere in your python code.

Demo:

More info here:
http://revitpythonwrapper.readthedocs.io/en/latest/forms.html#console

49 Likes

Really nice job, Gui :smiley:

1 Like

Sweet!

Awesome!

Love it, Thank you for sharing

Oh this is great! Thanks

wow cool!

This is great!

FYI @Zach_Kron @Racel

Very nice @Gui_Talarico… Lots of Python features being worked on by customers :slight_smile:

We have been wanting to add this functionality to Core for a while…

@Gui_Talarico - Would you be interested in submitting this to Dynamo Core, and have you thought about doing a Designscript debugger?

3 Likes

Thanks @Racel !

Hi @Racel_Williams. Sorry I missed your second msg. I don’t really know C# well enough to be able to contribute to Core at this time, but anyone is more than welcome to borrow from this and create better implementations.


A few people asked me for clarification on how to use the Console, so I am adding more details below:

How to use RPW’s Console to debug python code:

1. Install RevitPythonWrapper (rpw) through the package manager

Note: Note that rpw package ships with a GettingStarted.dyn you can use to familiarize yourself with how it’s used withing Dynamo.

2. Build the graph below using RPW_GetFilePath and python node.

import sys
sys.path.append(IN[0]) # Assumes RPW_GetFilePath output is IN[0]

from rpw.ui.forms import Console

for i in range(10):
	if i ==5:
		Console(context=locals())

8 Likes

That’s awesome, thanks!

Hi

please advise

Please include the python code, and the output form the get file Path node. Are you on latest version? (1.3 I think!)

I’m having the same issue. Did I skip something?
image
image

import sys
sys.path.append(IN[0]) # Assumes RPW_GetFilePath output is IN[0]

from rpw.ui.forms import Console

for i in range(10):
   if i ==5:
    	Console(context=locals())

I can’t reproduce this error here, so I will need someone who is having this problem to help us find the issue.

Here the source code of the GetFilePath node.
For some reason its not finding the file Path for the rpw library.

It assumes somewhere within ‘appdata/Dynamo’ it can find a folder called ‘RevitPythonWrapper’. The folder should be created when the package is installed:

import clr
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import os

appdata_path = os.getenv('appdata')
dynamo_path = os.path.join(appdata_path, 'Dynamo')

module_path = None
for root, subfolders, files in os.walk(dynamo_path):
	if 'RevitPythonWrapper' in subfolders:
		extra_path = os.path.join(root, 'RevitPythonWrapper', 'extra')
		module_path = os.path.join(extra_path, 'rpw.zip')

I assume that’s only if you use the default Dynamo location? If i store my packages in a different location I’ll probably have to change the path, correct?

EDIT: Yup, that’s it! I moved the package to the default location and it worked fine.

1 Like