Using PythonCAD FAQ

A stated goal of the PythonCAD project is to produce an easy to use CAD package. Still, questions will arise as to how to do some certain operation in PythonCAD. This page will hopefully provide answers to these questions. Keep in mind that the program is in its earliest form, so an answer stating that cannot be done as the code for doing that has not yet been written will be common. Over time, that answer should appear less and less frequently, and some happy day in the future it will not appear at all. If you are able to help develop the code and do so, that day arrives sooner.

PythonCAD mailing list archives

How do I ...

  • enter a point/radius/…?
  • work with layers?
  • print a drawing?
  • set the color/linetype/thickness/… of an object?
  • change the color/linetype/thickness/… of an object?
  • add a new linetype/style/dimstyle?
  • set dimension attributes?
  • enter commands?

This list is by no means complete, and will be added to as various new question arise.

Entering Data

If you are being prompted for a single value of something, like the radius of a circle, just type it in the entry field below the drawing. If you type in the value as an integer value (no decimal point), PythonCAD will convert it to a float value if needed. If it does not do this then you have found a bug. When PythonCAD wants you enter a point in the entry area below the drawing, it will expect you to enter the point in parenthesis, with the x and y coordinates separated by a comma. So, if you wanted to enter a point at the location (0.0,0.0), just type it in like that. You do not need quotes around the parentheses, nor around the digits. You can also type the same point without parenthesis 0.0,0.0.

Some effort is made to evaluate what you enter, so if you enter the point like this (3.4 + 5.5), (2.3 + 3.2), PythonCAD will create a point at (8.9, 5.5). Entering any arbitrary expression into will probably not work (yet), though at some point it is hoped that PythonCAD will be able to handle really complex expressions. As Python itself can handle the expressions, the weakness is in the PythonCAD code.


If you are brave enough to try PythonCAD R38 alpha 04 you have the chance to enter relative coordinates 2.3*2.5 from last point added. You can also directly type distance (like 5.04): angle will be desumed from mouse position. This works in ORTHO mode too!

Working with Layers

PythonCAD is built around the idea that a drawing is simply a collection of layers with various entities stored in each layer. There is no restriction as to how many layers a drawing may have. All drawings will have at least one layer, and, if you wanted to, you could put all the entities comprising the drawing in that single layer. As drawings get more complex, though, it will probably be clearer if you split up the entities between the layers. One idea could be to place all the dimensions in a layer, the construction lines and circles in another, etc. You will have to decide what works best for your particular needs.

Nearly all the layer operations can be done through the layer display on the side of the drawing. If you right-click a particular layer, a pop-up menu will appear. This menu gives you the choices of renaming the layer, hiding or showing it, hiding or showing any layers that are children of that layer, and clearing the layer, erasing all the objects stored in this layer. Eventually the code will allow you to drag and drop the layers so you can re-parent them as needed.

If you add a new layer, the new layer becomes the active layer. Any entities that are drawn will now be stored in this layer. If you want to change which layer is active, just click on the layer that you want to activate. When a drawing has multiple layers, the entities in the active layer are drawn showing what color they have. Entities kept in the inactive layers are all drawn the same color (a blue color by default), which can be chosen in the preferences dialog.

If you draw an object in one layer, and then decide you want to move it to another layer, you can do that through the use of the Transfer menu item in the Modify menu. After you invoke the menu item, you can click on the objects that you want to pull into the current active layer. Fillets and chamfers cannot be pulled from one layer to another just yet; this problem should be rectified in an upcoming release.

Printing and Plotting

As of the seventeenth release, PythonCAD can now print! The program will generate a PostScript file that can be sent to a printer or saved to a file. The initial printing support has several know flaws, such as not printing the dimension end-point markers like arrows or slashes. Subsequent releases will fix these problems as well as enhance the overall printing abilities of the program.

The strategy for printing support had always been to generate a file in some format that did not depend on the interface, and PostScript has filled that bill nicely. For people not using PostScript printers, there are third party software packages like Ghostscript that can convert the PostScript output into other formats.

Setting Object Attributes

Values for the object attributes in a drawing are set with the Set menuitem under the Draw menu. Depending on your choice of submenu a dialog box will appear and allow to to examine and change the attribute values as needed.

Changing Object Attributes

The ability to change an objects color, linetype, thickness, or style was added in the second release. First, you must select the objects that you want to change. Use the Select menu item in the Edit menu to select the entities that will get modified. Next, go to the Modify menu, and use one of the choices found in the Change submenu. After clicking OK in whichever dialog box that appears, the selected objects will now have the new attribute values from your menu and dialog choice.

Selecting an entity to change an attribute will cause the entity color to change indicating it has been selected. Once the attribute change has been applied, the entity will redraw itself. After changing an attribute of the selected entities, the selected entity list is cleared. This behavior may or may not be a considered a feature, and could change depending on user feedback.

Adding new Linetypes/Styles/Dimension Styles

There is no interface code written for doing this yet, so adding one of these things means delving into the code. There should be either a simple dialog box, or a sequence of dialogs, that will make it easy to do this sort of work, but none of that has been written. Also, questions regarding the saving and loading of these customized features will need answers, as the initial release (and probably many following releases) do not have any support for reading what would be a customization or preferences file.


For storing preferences, it is envisioned that there will be a global set of preferences stored in some file, and a user-specific set of preferences kept in each user's directory. If these files are written in Python code, then they could be brought into the program via an import statement, or the use of the imp module, though the decision as to what these files will be written in, let alone their format, has yet to be made. Feedback to the developers will determine what route to pursue. Other file format options are things like XML or some home-grown key/value text file.

Writing the preference files in Python does seem to present advantages over other formats, as there would be no need to try and write some sort of parser to read the file. Reading the file would be very quick, and any errors could be caught by a simple try/except block. Other alternatives could require more work for the importation of the data in the files. Still, it may be simpler to write the information out in a format other than Python, and that may be a deciding factor on just how to handle this problem.

Update: Storing the preferences as files written in Python has been implemented since the fifth release. This approach has utilized the imp module to load the file and, as the preference file is Python code, makes use of the Python interpreter to parse the file. This approach has worked reasonably well, and has provided a good initial implementation of storing and loading user preferences. At present editing the global preference file is done with a text editor, and probably requires root access as the file is hard-coded to reside in the /etc/pythoncad/ directory.

Update: As of the thirty-fifth release PythonCAD stores the global preferences values in the file ${HOME}/.pythoncad/ The file itself is Python code and can be edited directly, but care must be exercised if doing so. The values stored in this file are used when new Images are created, but the values can be adjusted later on a per-Image basis.


Some preference settings like toolbar position and window size are already stored and automatically reloaded on statup. We are providing extended preferences setup through new kernel database. This is planned to be ready for next alpha 5 release.


Dimensions are currently the most complex objects in PythonCAD. Any individual dimension has a large number of attributes that can be set, such as line and font color, dimension text position and formatting, and various properties relating to the dimension lines themselves. Dimensions are also at a very early stage in the code, so for all the things they can do, there are many lines of code still needing to be written in order to exercise all the dimension functionality that exists.

The fourth release of PythonCAD addressed many of the shortcomings in the earlier releases. Angular dimensions can be created, displayed, and saved, and linear dimensions will be displayed (they could be created but wouldn't show up). The display of the dimension text is also improved, and the interactive creation of dimensions now has some visual feedback to indicate the dimension points and text location. There is still much work to be added in making dimensions more flexible and editable, but progress is being made, and the fourth release contains vastly improved dimensioning capabilities.

General dimension properties can be set through the Preferences dialog box via the Edit menu. Dimension setttings within an Image can be adjusted by moving thorough the Draw→Set menus. Lastly, adjusting the attributes of an existing dimension within an Image can be done via the Modify→Change→Dimension menu path.


The seventh release of PythonCAD shipped with the first iteration of a command interpreter. The long-term goal with the command interpreter is to make it possible to use PythonCAD to a great extent by just typing commands in the entry box at the bottom of the screen. As this functionality is new, it is quite limited in what it can do at the moment. Future releases of PythonCAD will add more commands and enhance the usability of the command interpreter.

Visit this page for a description of the available commands in PythonCAD. commands_reference

Future of PythonCAD

Where is the KDE/Gnome/... Interface?

Hopefully arriving in the form of patches to each release. There is only so much code that can be typed in a day, and it was enough of a challenge to get the basic GTK interface running. Waiting to release a full implementation for all of GTK/GNOME/KDE meant many more months of work before anyone would see and use this program, and I wanted to get it released in a form where the first release had basic working functionality, and then iterate on the interface as feedback arrived. Writing a program for three distinct user environments and yet having a poor interface would be a waste of effort. If you want to see PythonCAD running with one of these other interfaces, then you will have to help in the development efforts. It would be wonderful to have a large development team working on PythonCAD, so come on in and lend a hand!


R38 interface is no more based on GTK (gimp interface), but on Qt throught the PyQt python bindings. Qt is used as default KDE4 environment too!

Can it read my existing CAD files? Will it ever?

Presently when we are developing R38 we have achieved import and export of few entities of DXF format. These entities are segment, circle, arc, text & polyline. While it is yet to address colors, layers and linetypes. With some more efforts we sould be able to address them.

At the first development release, PythonCAD could read nothing other than its own files. What more could anyone expect from a first release? Obviously the usefulness of the program is much, much greater if it can pull in files created by other CAD programs, and at some point PythonCAD will do this. As PythonCAD development progressed, documentation on the DWG format was found and code to read this format was created.

PythonCAD still lacks the ability to read files written in DWG as code to convert the output of the DWG reading code into PythonCAD entities has not been written. An additional difficulty in reading these files is that PythonCAD lacks support for some of the entity types used in AutoCAD drawings, with the largest omission being hatching. As PythonCAD continues to grow, it is hoped that the code for importing the DWG data will get added into the program.

Reading the multitude of file formats from other CAD packages is similarly unknown, as documentation about the format will be required. The developer time needed in writing the translator, once suitable documentation is obtained, is another issue entirely.

I believe that writing the translating program in Python will be simpler than writing a C translator - Python can deal with binary data with the struct module - so if the documentation is available, and someone puts in the coding effort, the importation code will be added as quickly as possible.


R38 support for DXF reading is in it's first stage, but it still works for points, lines, polylines and other basic cad entities. We are planning DXF output too. DWG support will be based on LibreDWG since python binding for that code is nearly completed. So we depend from them for the support.

Can PythonCAD do 3-D drawing?

Not directly, and it probably never will. Doing a 2-D CAD package is enough of a challenge; a good 3-D package would be significantly harder. There are billions of 2-D CAD files in existence, and they will always need some means of viewing. If enough translators get created, maybe PythonCAD can read a large percentage of those files.

Feature requests

faq.txt · Last modified: 2012/06/19 20:29 by relue