Skip to main content

Libraries

Parametric SVG drawings can be created by using the parameter block in the Visual Model or defining a list of var statements in the header of the script in Text mode. All JavaScript variables defined in the header of the file are converted to function parameters.

Visual Mode

To add a parametric part to a drawing open the elements menu and select the part block. Drag the block into the workspace and optionally enter a name of the library where the part is located. In this case the name is AIR. Then click on the dropdown menu and select the part you want to add. When the part is added, the block definition of the part is updated to include the list of parameters, such as speed or pitch and bank. You can enter a number, variable or expression. The example below shows how you can make PFD (Primary Flight Display) for a glass cockpit airplane. The PDF contains the various other drawings, such as the speed indicator, horizon, altitude indicator and compass.

Text Mode

The script below shows the same example in Text Mode. The part functions include the name of the library, the name of the drawing, followed by an optional list of parameters. The parameters are separated by commas and can be numbers, variables or expressions.

var speed = 138
var heading = 312
var altitude = 1750
var altSelect = 3000
var pitch = 5
var roll = 15

part("AIR.Speed tape", speed)
translate(70,0)
part("AIR.Horizon",pitch, roll)
translate(570,0)
part("AIR.Altimeter tape",altitude, altSelect)
translate(70,500)
fill('#cccccc')
translate(0,0)
width(0)
rectangle(230,310,180, 180,10)
translate(240, 320)
scale(0.8, 0.8)
part("Aircraft compass", heading)

SVG

After saving the model an SVG can be generated from a web page or by entering a URL with the parameters in a browser.

http://localhost:8010/drawings/svg/AIR.PFD(150,10,2700,4000,-15,-5)

This URL includes the name of the library, the name of the part and the list of parameters in the same order as defined in the drawing. The first parameter is the speed in knots, followed by the compass heading etc.