cad4tcl

cad4tcl is a graphic library providing CAD-specific canvas functions and was developed as a part of rattleCAD.
So let me tell you about the background of this library:

rattleCAD

rattleCAD is a parametric CAD application for bicycle frame builders and is a pure TclTk application and as a CAD application rattleCAD supports:

  • zoom in the canvas and
  • pan the view
  • create
    • dimensions and
    • drafting frames
  • import
    • SVG graphics and
  • export
    • SVG
    • PDF and
    • DXF (on tk::canvas only).

rattleCAD (3.6) provides this features using cad4tcl.

tk::canvas and tkpath

There are currently (2018) two main graphic libraries available in the Tcl / Tk environment.

  • tk::canvas provides pixelated representation only. Even the overlapping of graphic elements with cutouts can only be achieved with temporary solutions, if at all.
  • tkpath implements path drawing modeled after SVG and was developed by Mats Bengtsson (1959-2008). While the tk::canvas does not support antialising nor can it display transparent clips, tkpath is very flexible and reproduces all standard drawing canvas items. Features include: opacity, antialiasing, gradient fills, affine transformations, and fill rules and includes Tk drawing as a fallback.

While tk::canvas is part of the tcl core tkpath is not.


cad4tcl

In one of the of course necessary refactoring projects of rattleCAD - among others - the 2D CAD functionalities were extracted into a separate library using TclOO.
In the case of cad4tcl it was important to me to support both:

  • tk::canvas and
  • tkpath

depending on availability of tkpath. Based on supporting these canvas libraries only

  • one common interface
  • inspired by tk::canvas

should make it easy to put cad4tcl between your current application and your tk::canvas or to replace tk::canvas with tkpath.

While of course cad4tcl also bases on a lot of ideas and sample code of kind tcl developers and rattleCAD is very specific to bicycles and bicycle geometries I can imagine that cad4tcl will also be usefull for other applications outside of rattleCAD.

So I decided to publish this library as open source library outside of rattleCAD under the BSD License and say a big and fat THANKS to everyone who provided any examples anywhere that I could learn from.

External libraries

cad4tcl at least requires some external packages to provide its own features:

  • Tk
  • TclOO
  • tdom
  • math (part of tcllib)
  • math::geometry (part of tcllib)

for some additional features the following packages are required:

  • pdf4tcl (to export pdf)
  • tkpath (to be used instead of tk::canvas, of course)
  • svgDOM (simplify SVG for performance issue)

Projects & Repositories @ sourceforge.net

The cad4tcl project is hosted on sourceforge.net

related projects

... feel free to participate!