DMelt:Plots/Technical Drawings

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member

Technical drawings

DMelt supports technical drawings using net.sf.drawj2d.Drawj2d class. One advantage of the package is that you create images directly in the SVG file format, thus images are fully scalable.

Let us consider an example.

from jhplot import *
from net.sf.drawj2d import Drawj2d


# variables
set dx 50
set dy 20
# draw
moveto 20 10
label P NW
rectangle $dx $dy
pen 0.35 red
arrowrel $dx $dy
label Q SE
# dimension lines
pen black
moveto 20 42
dimlinerel $dx 0
moveto 82 10
dimlinerel 0 $dy
with open(f, "w") as xfile:

args=["-T" "svg", "-W", "100", "-H", "60", "-o", out, f]

This example creates a file with the commands to draw a technical image. Then we read this file, create a SVG scalable image and open this image in jhplot.IViewSVG viewer. The output is:

DMelt example: Showing techical rectangle

The complete syntax of the files where drawings are defined is this manual:

More information on this topic is in DMelt books