|
|
|
|
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
-
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:
-
Massive changes in move,delete,scale,rotate commands.
-
Old select routines were deleted.
-
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.
-
thanlcd font, thantimes font (not finished).
-
Import .shp font file.
-
Command select (element/window/crossing/previous).
-
Command list.
-
Command erase.
-
do/undo mechanism.
do/undofor erase command.
-
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.
-
Command move and copy.
-
Zoom in/out can be done with middle wheel of the mouse.
-
Export to PIL has a GUI now (not finalised).
-
Command Rotate was cleaned and decorated with undo/redo
functions.
-
Export to PIL image and then print as a workaround
to print a drawing.
-
Command Scale was cleaned and decorated
with undo/redo functions.
-
ThanCad was presented in EuroPython
2007, Vilnius, Lithuania.
-
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!
-
New status bar supports
view of pixel coordinates when the cursor is over
raster images.
Toggle between world/pixel coordinates with F7.
-
Beginnings of GIS support (see educational menu).
-
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:
-
Area command implemented.
-
Fillet command was implemented.
-
List command shows length, area for line, circles, arcs.
-
Purge (for layers) was impemented.
-
The command highlight was
implemented for very small ovjects to become visible in Tkinter.
-
The command trim was implemented for lines/polylines, circles and
arcs. It was more difficult than I thought. It took me all day.
-
The command hull was implemented for lines/polylines. It finds the
2d convex hull of the nodes of the lines.
-
The centroid was
implemented for lines/polylines. It finds the ndimensional centroid
of the (closed or open) lines.
-
Line hatch of open (not closed)
shapes was implemented.
-
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 :)
-
Extensive translation to Greek.
-
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.
-
The OSNAP "per"
infrastructure was implemented. The "per" for arcs,
circles, lines was implemented.
-
Various algorithms for ICP
with lines (published only in scientific papers).
-
The reverse
command was implemented. It reverses the orientation of direction of
lines.
-
The mirror command was implemented. It mirrors elements
with respect to a line.
-
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).
-
The "ddedit"
command was implemented.
-
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?
-
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.
-
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.
-
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:))
-
Import from linicad (http://sourceforge.net/projects/linicad/) was
implemented. Request by a user (guess who!).
-
The Spline element was added.
-
The copy/cut/paste was fixed. Control-C, Control-X, Control-V now work.
-
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.
-
The dimensions of the last drawing window are saved, so that new windows
are drawn with the same dimensions.
-
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.
-
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.
-
The named point was (fully) implemented. The poedit (point edit) command
was also implemented to make point handling easier.
-
The plot command is partially implemented. Hooray! It can also save to
a postscript file for later printing or (pre)viewing.
-
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.
-
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.
-
I began to write a new format for ThanCad, which is an xml file.
-
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.
-
The transformation command in the research menu was more or less
implemented. I began working on it in April 2010.
-
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.
-
The open command opens multiple drawings at once, now.
-
The save/saveas commands were implemented (the previous save
command was really the saveas command).
-
The do/undo mechanism was implemented for continueline,
trim commands.
-
Explode was implemented for the aligned dimension element.
-
I have been implementing the do/undo mechanism for all ThanCad's commands
since last month. Many weeks more are needed.
-
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.
-
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.
-
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.
-
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.
-
Image log command can open multiple .log files at once.
-
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.
-
F6 now toggles coordinates on and off (as the mouse moves).
-
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.
-
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.
-
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.
-
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)
-
ThanCad was presented in the EuroPython conference held in Vilnious,
Lithuania, July 9-11, 2007.
The presentation is here.
-
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:
-
www.ktim.gr used ThanCad to create private cadastre maps in 2008 (sadly the site is no longer
functioning).
-
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.
Last
Updated: October 20, 2010