SourceForge.net Logo stopsoftwarepatents.eu petition banner

Athens

FSFE Newsletter ThanCad
2dimensional cad for engineers


GENERAL

ThanCad is a 2dimensional cad, with raster inclusion capability and emphasis in engineering.
It is being written in Python and since it uses the Tkinter library, it is
platform independent! It will also be easy to translate it to various languages.
ThanCad is published under
GPL.

DEVELOPMENT STEPS

The development will proceed with the following steps:

1. Store the drawing elements in memory so they can be accessed fast.
2. Visualize the drawing elements into screen.
3. Get interactive input from the user (mouse click drag, typed commands etc.).
4. Create simple elements and capabilities (points, lines, layers, colors etc.).
5. Implement layers.
6. Design the user interface so that it can easily be translated to various languages
(command line is necessary).
7. Store drawings to disk.
8. Plot drawings to plotters and printers.
9. Export to dxf (easy) and Import from dxf (difficult).
10. Insert raster into drawings.

CURRENT STATUS (October 20, 2010)

I am developing ThanCad in my free time, so the progress is slow. Right now steps 1-7, 9-10 are
ready or partially implemented.
Step 8 has, at last, been partially implemented, using the Tkinter ability to produce postscript (with some workarounds). This is coupled with the ability of CUPS to transparently integrate GhostScript (SuSE only?), so that postscript will print to any printer!
The drawing elements are stored in standard python data structures.
Element access is moderately fast for Python!
The GUI is split to 2 components. The first is library independent and deals with abstract windows,
menus etc. The second is library dependent and it implements windows, menus etc. Thus it is easy to
port the GUI to various libraries. Until version 0.0.2 wxPython was used as a library (wxPython is a
wxWindows wrapper). Later versions use Tkinter (Tkinter is the defacto library that comes along
with python). The reason for this change is that wxPython didn't seem, then, to work properly under
Linux. In the future the GUI may be ported to other libraries.
Right now the object snap perpendicular mode is being implemented.

FEATURES

At first be warned that ThanCad is slow because it is written in Python. Do not expect the speed that commercial CAD have. But because it is written in a very flexible high level language, its development is at least 10 times faster. In fact I do not think I would have the patience to make it in C++. I think that 3 features will make ThanCad better -well- than cad:
1. ThanCad is free. It is published under GPL, the GNU General Public License. This means that you don't pay anything for it, you can copy it as many times as you like, you can give it to a friend, and you can use it in your home and in your business. If you are a programmer, you can modify and/or extend ThanCad, or you can base your software on it. But if you intend to publish the modified/extended ThanCad (you may want to sell it), you must give your customers at least the rights that you have with ThanCad. Please see GPL for details.
2. ThanCad is written in python, so it is -at least it should be- platform independent. ThanCad should run unmodified in Windows 98/Me/NT/2000/XP, in Linux, in MACOS, Solaris etc. wherever python runs. I know of some companies that can not switch to Linux, although they have ported all software to Linux, because they depend on a commercially available CAD which runs only in a certain platform. ThanCad will free you to use the OS of your choice. ThanCad is currently being developed in OPEN SuSE Linux 11.0. From time to time I run it under Windows XP. It is sentimental to see the program behave the same way under Linux and Windows, without changing a single line of code!!!
3. ThanCad supports the "layer sublayer" concept. This means that a layer may contain sublayers and the sublayers may contain subsublayers etc. Each layer will have a set of attributes such as color, line type, visibility, draw order, transparency etc., which will be shared by all the elements the layer contains. The sublayers inherit the attributes of their parent by default. But you can overwrite any attribute if you want. For example imagine that you draw your house. Suppose you have a ground floor and a first floor. Naturally you create one layer for each floor. For the first floor you have the walls, the furniture, the various cables, the hydraulics. You can create a separate sublayer with different colors for each category. The same must be done for the ground floor. No problem, just copy the sublayer structure of the layer of the first floor to the layer of the second floor. The colors are already set. If you want to examine the first floor, make the layer of the ground floor invisible and all its sublayers are automatically made invisible too! Suppose you want to change the color of the furniture of the first and the ground floor. Select the common sublayers of the two layers and change the color of the sublayer of the furniture. Then you want to draw a garden. Create a layer "house" and put the layers of the ground and the first floor into it, as sublayers. Make this layer invisible, and you are free to draw the garden. Now try to do all the above with another CAD.

BUGS

- ThanCad is slower in Windows than in Linux. This is probably because Tkinter is slower in Windows than in Linux. Unfortunately newer version of Tkinter have not addressed this problem. Perhaps it is not possible.
- The font of the text is built in since Tkinter does not support rotated fonts. This means that standard X-fonts or Windows fonts are not available.
- The zoom all command sometimes does not zoom to the entire drawing. In this case
run regen and retry.
- Many of the objects which contain references to Tkinter widgets are not destroyed
when they are deleted because there are circular references. Spotting the circular references has proved to be difficult. The result is memory leaks.
- Finally I am sure there are many other bugs buried here and there in the code.

DOWNLOADS

ThanCad is usable if you care to save your work frequently. It can read and write dxf files, it can zoom and pan, and it can add lines, circles, points, images etc. interactively. Since layers are partially implemented all lines are continuous. The drawing may have various colors though. The latest code is published in sourceforge, as soon as I find the time to upload it!

IMPROVEMENTS

After the basic program is up and running, the following improvements might be considered:

1. Add new drawing elements (bezier curves, solids etc.).
2. Add utilities (trimming, extending, intersecting, dimensioning etc.).
3. Add raster editing.
4. Implement various algorithms (triangulation, contour lines etc.).
5. Add profession-specific capabilities (for example cross section of a highway,
profile of a conduit, circuit analysis, etc.).
6. Move the code to C and/or Fortran, for faster execution.

HISTORY

- Version 0.0.1 could only store elements in a structure, without graphical User Interface (GUI).

- Version 0.0.2 added a wxPython GUI. Lines, circles, and texts were implemented. Import
from dxf was partially implemented.

- Version 0.0.3 changed to Tkinter GUI. Export to dxf was implemented.

- Version 0.0.4

-Version 0.0.5 - Version 0.0.6 - Version 0.0.7 “Bond” - Version 0.0.8 “DoSomething” has so many enhancements that it is difficult to remember. Here are some:
  1. Massive changes in move,delete,scale,rotate commands.
  2. Old select routines were deleted.
  3. Plot (export) to raster image.
  4. F3 toggles OSNAP on/off.
    control arrowup/control arrowdown pans the drawing up/down.
    control arrowleft/control arrowright pans the drawing left/right.
    gray+/gray- zooms in / zooms out.
  5. thanlcd font, thantimes font (not finished).
  6. Import .shp font file.
  7. Command select (element/window/crossing/previous).
  8. Command list.
  9. Command erase.
  10. do/undo mechanism.
    do/undofor erase command.
  11. Added an option to insert a raster image as follows:
    a. The insertion point is at -0.5, -0.5 user units
    b. The scale is 1 pixel is 1 user unit.
    This is needed for rectification of scanned topographic maps, which have errors due to contraction of paper, and scanner errors.
  12. Command move and copy.
  13. Zoom in/out can be done with middle wheel of the mouse.
  14. Export to PIL has a GUI now (not finalised).
  15. Command Rotate was cleaned and decorated with undo/redo functions.
  16. Export to PIL image and then print as a workaround to print a drawing.
  17. Command Scale was cleaned and decorated with undo/redo functions.
  18. ThanCad was presented in EuroPython 2007, Vilnius, Lithuania.
  19. Conversion to limited z capability. All elements accept z coordinates. In fact ThanCad has now n-dimensional support. All adaptations to the code for the z-coordinate, also support arbitrary number of dimensions. Physicists this CAD is for you!
  20. New status bar supports view of pixel coordinates when the cursor is over raster images. Toggle between world/pixel coordinates with F7.
  21. Beginnings of GIS support (see educational menu).
  22. Internal support for embedding other applications into ThanCad (for developers).
-Version 0.0.9 “DoesSomething” has also many enhancements that it is difficult to remember.
Here are some:
  1. Area command implemented.
  2. Fillet command was implemented.
  3. List command shows length, area for line, circles, arcs.
  4. Purge (for layers) was impemented.
  5. The command highlight was implemented for very small ovjects to become visible in Tkinter.
  6. The command trim was implemented for lines/polylines, circles and arcs. It was more difficult than I thought. It took me all day.
  7. The command hull was implemented for lines/polylines. It finds the 2d convex hull of the nodes of the lines.
  8. The centroid was implemented for lines/polylines. It finds the ndimensional centroid of the (closed or open) lines.
  9. Line hatch of open (not closed) shapes was implemented.
  10. Computation and creation of highway Interchange. This was an existing program that was really awkward to use with thAtCad (leading commercial CAD :)). I integrated it into ThanCad and now it is very satisfying. It helps when you make the _CAD code_ suit the application, and not the other way round :)
  11. Extensive translation to Greek.
  12. The Curve element, which is a curve represented by many small line segments. The OSNAP end, tan and cen were implemented. I tested the curve with a klothoid with good (approximate) results.
  13. The OSNAP "per" infrastructure was implemented. The "per" for arcs, circles, lines was implemented.
  14. Various algorithms for ICP with lines (published only in scientific papers).
  15. The reverse command was implemented. It reverses the orientation of direction of lines.
  16. The mirror command was implemented. It mirrors elements with respect to a line.
  17. The script file was implemented. It runs ThanCad commands from a file. Also, the thancad.scr script is read at start, if it is found in the directory .thancad (~/.thancad or $windir/.thancad in WinDoze).
  18. The "ddedit" command was implemented.
  19. The ortho mode was implemented. The last 2 changes made me realise that none of the changes/additions to ThanCad have been trivial. They needed cosiderable effort, because of their relationships to the other parts/mechanisms of ThanCad. Luckilly Python was there to ease the coding. How did you cope before Python?
  20. The "fill" layer attribute was implemented. If "fill" is True then all closed lines (closed polylines, circles) are filled with solid colour (or hatch in the future). The polygon element was converted to a command which creates a closed polyline.
  21. The 'fill' command was implemented. It sets the 'fill' attribute of all layers to ON.If all the leaf layers have the 'fill' attribute on, this is reflected to the 'fill' variable when exporting to .dxf format.
  22. The 'ThanLineFilled' element was implemented, which is essentially a closed polyline filled with colour, even if it belongs to a layer with the attribute 'fill' set to off. This is for compatibility with leading commercial CADs, and it is certainly inferior to the 'fill' attribute mechanism. The solid command command now creates a filled triangle or quadrilateral which are filled polylines. The data is entered with the crazy way of the leading commercial CADs. The filled polylines with 3 or 4 nodes are exported to dxf format as solids.

-Version 0.1.0 “Photogrammetric”
Here are the enhacements (most of them as it is hard to rember them all:))
  1. Import from linicad (http://sourceforge.net/projects/linicad/) was implemented. Request by a user (guess who!).
  2. The Spline element was added.
  3. The copy/cut/paste was fixed. Control-C, Control-X, Control-V now work.
  4. When a point (coordinates) is asked from the user, the user may type end,int,cen,non etc. to override temporarily the object snap settings.
  5. The dimensions of the last drawing window are saved, so that new windows are drawn with the same dimensions.
  6. The scan command was implemented. This was a request from a user (my son!). It uses the pysane package. If pysane is not installed, or if there are no scanners, it creates a fake scanner. The fake scnanner 'scans' always the same image, but it shows the functionality.
  7. Automatic computation of a floor plan. This was an existing program that was integrated into ThanCad. Now it is much more convenient and flexible to use. This is part of active research.
  8. The named point was (fully) implemented. The poedit (point edit) command was also implemented to make point handling easier.
  9. The plot command is partially implemented. Hooray! It can also save to a postscript file for later printing or (pre)viewing.
  10. The 'language' command was implemented. You can type 'language' in the command prompt, or select it from the help menu (the last menu on the right). This command changes the language of ThanCad's interface. ThanCad must be restarted so that all messages are in the new language. English and Greek is supported so far. The 'language' command and the menu entry is always in English, for obvious reasons. If the language is not english, when ThanCad begins execution, it print a message on how to change the language. The message is always in English.
  11. The reference point of the rotate and scale command can now be the insertion point of each element. Thus each alement will be scaled or rotated with respect to its insertion point. This change was done last year - I just remembered it.
  12. I began to write a new format for ThanCad, which is an xml file.
  13. The command text find in the tools menu will now search for text of named points too. Also, pressing ctrl-F will trigger the find command.
  14. The transformation command in the research menu was more or less implemented. I began working on it in April 2010.
  15. The point element now has a finite size (not zero size) according to the dimensions of the symbol and name and height (if it is a named point). The dimensions of the symbols etc are taken relative to the screen size, so that a regen before zoom extents is needed.
  16. The open command opens multiple drawings at once, now.
  17. The save/saveas commands were implemented (the previous save command was really the saveas command).
  18. The do/undo mechanism was implemented for continueline, trim commands.
  19. Explode was implemented for the aligned dimension element.
  20. I have been implementing the do/undo mechanism for all ThanCad's commands since last month. Many weeks more are needed.
  21. I finished the offset command and corrected bugs in the line offset (it still has some non-critical bugs). I also implemented the offset command for circles, arcs and points. I don't think the offset command is needed for texts, images.
  22. I added new command imagelocate. This command may locate the actual image file of a ThanCad image, if it was not found. Or it can change the image file to something new.
  23. I added new command imagedirectory. This command defines a directory, where ThanCad will search for missing image files, for all ThanCad images, which the image file was not found of.
  24. I added new command imagelog. This command reads a .log file produced by my orthophotography program and inserts and puts an image to their correct location with the correct scale automatically. Multiple .log files may be opened at once.
  25. Image log command can open multiple .log files at once.
  26. Milestone! ThanCad has a second developer (I hope it lasts). She implemented cosys which creates a non-cartesian coordinate system, given two (non-)parallel axes. Then, she enhanced F7 which now toggles between world coordinates, cosys coordinates (which are named "image" coordinates) and pixel coordinates.
  27. F6 now toggles coordinates on and off (as the mouse moves).
  28. The image insertion was changed so that the image can be inserted in mm. If the resolution of the image can not be determined (for example for .gif images), ThanCad asks for the resolution.
  29. A new menu was added for photogrammetry. It uses the functionality of ThanCad to import images in mm, and then define the "image" coordinate system. It also draws the axes of the non-cartesian system.
  30. Sometimes the raster images are not in the right orientation and they must be rotated by 90, 180, or 270 degrees with GIMP, before they are inserted into ThanCad. Not any more. ThanCad is now able to rotate an image by 90, 180, and 270 degrees (counterclockwise). The insertion point and the scale of the the image is not affected. In fact the insertion point ren\mains the lower-left point of the rotated image. For 180 degrees, the image geometry is not changed at all.
  31. Andreas Stamos (age 8), created the setup.py for py2exe, in order to make ThanCad executable in WinDoze. It worked almost painlessly. The only glitch was that various plugins of the Python Image Library (PIL) had to be imported explicitely (usually "import Image" imports dynamically the plugins that are needed).

-Version 0.1.1 “Photogrammetric”
Some bugs were fixed and imageclip was implemented. Image clip affected all the code related to raster images. And there is room for optimisation.


AUTHORS

Thanasis Stamos
----Residence: Athens, Greece, Europe.
----E-mail:
cyberthanasis@excite.com

PAPERS ABOUT THANCAD (directly or indirectly)

  1. ThanCad was presented in the EuroPython conference held in Vilnious, Lithuania, July 9-11, 2007.
    The presentation is here.
  2. The Binary Spatial Partitioning Tree data structure, which is used by ThanCad, was presented in The Sixth International Conference on Engineering Computational Technology, Athens, Greece, 2-5 September,2008. 
    The presentation is here.

PROJECTS WHICH USE THANCAD (directly or indirectly)

ThanCad has been used for commercial and academic purposes:

  1. www.ktim.gr used ThanCad to create private cadastre maps in 2008 (sadly the site is no longer functioning).
  2. The National Tecnhical University of Athens uses ThanCad for educational purposes (1 semester 2010-2011).
    Dimitra Vassilaki, a researcher of the Laboratory of Photogrammetry, School of Rural and Surveying Engineering, has contributed code for basic photogrammetry. She uses ThanCad as teaching tool in the laboratory. The students make measurements on real-world aerial images loaded in ThanCad.


  3. Last Updated: October 20, 2010