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 (September 6, 2008)
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. 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.
- There is also a problem with the graphics in Windows
98 (the window flickers when the
mouse moves – not always.
Windows XP does not have this problem.
- 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
has better dxf import. Pan, zoom were greatly enhanced. Regenerations
now
happen when it is necessary. Some bugs in the open/close
commands were fixed. The
beginning of nested layers has been
implemented. The quadtree structure was dropped
because the
overhead was bigger than the gain in small to medium drawings.
-
Version 0.0.5 has raster image support. Select window and select
crossing has been
implemented. Layers have 2 working attributes;
color and frozen. Creation of a topographic
grid was implemented -
for engineers at last :)
The beginning of international
translations was done.
Finally the drawing is saved in internal
format, using Python's pickle. This overcomes
the deficiencies of
dxf format.
- Version 0.0.6 has now a working command line.
Object snap is quite implemented;
and it works fast - that was a
surprise.
- Version 0.0.7 “Bond” has better and
colored command line. The name of the commands
are now more
“familiar”. So are the menus.
Another layer attribute,
DrawOrder, was implemented which is an integer number; layers
with
higher DrawOrder are drawn over the layers with lower DrawOrder.
The
selection (or new definition) of layer colors is much better (and
finalised).
Object snap now includes EndPoint, MidPoint, Center,
Node, Quadrant, Intersection,
tangent, nearest modes; theres is
also a nice window for the selection of object snap mode.
Right
clicking when no command is running pops a menu with common
commands.
Right clicking when zoom rt is active quits zoom and
starts pan rt (and vice versa).
Semi-automatic line tracing of a
bitmap (b/w) image is partially implemented.
The first steps to
the units command were made.
The first unsuccessful steps to the
nesting of commands were made.
The rectangle command is a
convenience. It draws a closed line shaped as a rectangle.
-
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.
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.
4.
thanlcd font, thantimes font (not finished).
5. Import .shp font
file.
6. Command select (element/window/crossing/previous).
7.
Command list.
8. Command erase.
9. do/undo mechanism.
do/undo
for erase command.
10. 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.
11. Command move and
copy.
12. Zoom in/out can be done with middle wheel of the
mouse.
13. Export to PIL has a GUI now (not finalised).
14.
Command Rotate was cleaned and decorated with undo/redo
functions.
15. Export to PIL image and then print as a workaround
to print a drawing.
16. Command Scale was cleaned and decorated
with undo/redo functions.
17. ThanCad was presented in EuroPython
2007, Vilnius, Lithuania.
18. 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!
19. New status bar supports
view of pixel coordinates when the cursor is over
raster images.
Toggle between world/pixel coordinates with F7.
20. Beginnings of
GIS support (see educational menu).
21. Internal support for
embedding other applications into ThanCad (for developers).
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
is used for commercial purposes!
-
www.ktim.gr
They use ThanCad to create
private cadastre maps.
Last Updated: September 6, 2008