Debugging Python Code

python

#1

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


Is it possible to debug Dynamo python code using JetBrains PyCharm?
Python Code in Dynamo - testing?
Can't modify multiple assembly origins via python, only one at a time
Unresolved!
#2

Really nice job, Gui :smiley:


#3

#4

Sweet!


#5

Awesome!


#6

Love it, Thank you for sharing


#7

Oh this is great! Thanks


#8

wow cool!


#9

This is great!


#10

FYI @Zach_Kron @Racel_Williams


#11

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…


#12

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


#13

Thanks @Racel_Williams !


#14

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())


RevitPythonWindow 1.6.0 - installation problem
#15

That’s awesome, thanks!


#16

Hi

please advise


#17

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


#18

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())

#19

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')

#20

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.