Python Debugging: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (→‎Debugging with Aptana Studio: fix also other links)
Line 6: Line 6:
== Debugging with Aptana Studio ==
== Debugging with Aptana Studio ==


I have experimented with Aptana Studio (http://www.aptana.com/products/studio3) which is a version of http://en.wikipedia.org/wiki/Eclipse_(software)
I have experimented with Aptana Studio (http://www.aptana.com/products/studio3/download.html) which is a version of http://en.wikipedia.org/wiki/Eclipse_(software)
 


Aptana is an IDE that allows you to manage Python projects and can debug remote python engines like Vectorworks. It includes PyDev (http://pydev.org/) for that which, by itself, is a plug-in to do python in Eclipse.
Aptana is an IDE that allows you to manage Python projects and can debug remote python engines like Vectorworks. It includes PyDev (http://pydev.org/) for that which, by itself, is a plug-in to do python in Eclipse.


Anyway, you can remote debug, and here is how:
Anyway, you can remote debug, and here is how:
http://pydev.org/manual_adv_remote_debugger.html
http://pydev.org/manual_adv_remote_debugger.html


Here is the setup procedure:
Here is the setup procedure:
# Install Python 3.3 runtime (http://www.python.org/download/) I’ll hook Aptana to this version later. This is technically not necessary, but I prefer to have it so Aptana could report syntax errors while editing.  
# Install Python 3.3 runtime (http://www.python.org/download/) I’ll hook Aptana to this version later. This is technically not necessary, but I prefer to have it so Aptana could report syntax errors while editing.  
# Install Aptana Studio 3 (http://www.aptana.com/products/studio3)
# Install Aptana Studio 3 (http://www.aptana.com/products/studio3/download.html)
# Run Aptana and specify a workspace directory outside Vectorworks path. This is VERY important for the reason that workspace directory will contain a ton of files that start with ‘.’. If this path is visible by Vectorworks, it will make it launch very slowly (from traversing all these files and sub-folders)
# Run Aptana and specify a workspace directory outside Vectorworks path. This is VERY important for the reason that workspace directory will contain a ton of files that start with ‘.’. If this path is visible by Vectorworks, it will make it launch very slowly (from traversing all these files and sub-folders)
# Now, you can create a project. File -> New -> Project (General)
# Now, you can create a project. File -> New -> Project (General)
# Only the first time, this process would require to setup Python engine. Now, let the software find the python and set it up automatically. This is the point where it will find the Python you installed in step 1. This is ok, since we wont actually using it, but will let Aptana use it to syntax check.  
# Only the first time, this process would require to setup Python engine. Now, let the software find the python and set it up automatically. This is the point where it will find the Python you installed in step 1. This is ok, since we wont actually using it, but will let Aptana use it to syntax check.  


The way the debug works is to use the remote debugger of Aptana: http://pydev.org/manual_adv_remote_debugger.html
The way the debug works is to use the remote debugger of Aptana: http://pydev.org/manual_adv_remote_debugger.html
Line 47: Line 43:


Then you go to Aptana Studio and enable the remote debugger (http://pydev.org/manual_adv_remote_debugger.html) and run your script in Vectorworks.
Then you go to Aptana Studio and enable the remote debugger (http://pydev.org/manual_adv_remote_debugger.html) and run your script in Vectorworks.


== See Also ==
== See Also ==


Python basic information: [[Python]]
Python basic information: [[Python]]

Revision as of 11:32, 4 May 2015

Python is open source scripting engine and there are many free and paid IDEs that can hook into the engine and debug. I guess you can search and experiment with what is out there in the internet. Maybe you can find an easier way to make it work.

.Python|Python ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix ..Python Debugging|Debugging with Python

Debugging with Aptana Studio

I have experimented with Aptana Studio (http://www.aptana.com/products/studio3/download.html) which is a version of http://en.wikipedia.org/wiki/Eclipse_(software)

Aptana is an IDE that allows you to manage Python projects and can debug remote python engines like Vectorworks. It includes PyDev (http://pydev.org/) for that which, by itself, is a plug-in to do python in Eclipse.

Anyway, you can remote debug, and here is how: http://pydev.org/manual_adv_remote_debugger.html

Here is the setup procedure:

  1. Install Python 3.3 runtime (http://www.python.org/download/) I’ll hook Aptana to this version later. This is technically not necessary, but I prefer to have it so Aptana could report syntax errors while editing.
  2. Install Aptana Studio 3 (http://www.aptana.com/products/studio3/download.html)
  3. Run Aptana and specify a workspace directory outside Vectorworks path. This is VERY important for the reason that workspace directory will contain a ton of files that start with ‘.’. If this path is visible by Vectorworks, it will make it launch very slowly (from traversing all these files and sub-folders)
  4. Now, you can create a project. File -> New -> Project (General)
  5. Only the first time, this process would require to setup Python engine. Now, let the software find the python and set it up automatically. This is the point where it will find the Python you installed in step 1. This is ok, since we wont actually using it, but will let Aptana use it to syntax check.

The way the debug works is to use the remote debugger of Aptana: http://pydev.org/manual_adv_remote_debugger.html

First, you must include an import to the PyDev remote debugger in your script. The Python Sample Menu Command contains commented code that enables PyDev debugger.

import pydevd
pydevd.settrace(suspend=False)

Then your script will fail because the 'pydevd' module is not found.

To fix that you must point Vectorworks' Python to the correct path to find the missing module.

Go to the Vectorworks menu Tools -> Plug-ins -> Script Options and add the path to the location: D:\Aptana Studio 3\plugins\org.python.pydev_2.7.0.2013012902\pysrc

Note: you may need to change that to the place where you have installed the Aptana Studio.


Then you go to Aptana Studio and enable the remote debugger (http://pydev.org/manual_adv_remote_debugger.html) and run your script in Vectorworks.

See Also

Python basic information: Python