#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";
// simple sketch showing the usage of some primitive forms
var w = 10; // we use this for easier calculation
function draw(){
b.clear(b.doc()); // clear the current document
b.units(b.MM); // we want to print. use MM intead of default pixels
b.rectMode(b.CENTER); // draw rects from the center
b.ellipseMode(b.CENTER); // draw ellipses from the center
var doc = b.doc(); // a reference to the current document
// set some preferneces of the document for better handling
doc.documentPreferences.properties = {pageWidth:200,pageHeight:200};
doc.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
// now draw some shapes
var rect = b.rect(b.width/2 + w *2 ,b.height/2,w*4,w*4); // a rectanlge
var ellipse = b.ellipse(b.width/2 - w * 2,b.height/2,w*4,w*4); // a oval
// b.strokeWeight = 10; // has no effect
var line = b.line(b.width/2 - w * 2,b.height/2 + w * 2,b.width/2 + w * 2,b.height/2 + w * 2); // GraphicLine
// var arc = b.arc(b.width/2, b.height/2, w,w,b.radians(90),b.radians(20), b.OPEN); // not working currently
b.noFill(); // now don't fill the polygon we are going to draw
// you can create polygons or graphicLines this way.
// if you close them they are polygons
// if not grphicLines
b.beginShape(/*b.CLOSE*/);
b.vertex(b.width / 4, b.height / 2 + w * 4);
b.vertex(b.width / 2, b.height / 2 + w * 3, b.width / 4, b.height / 2 + w *2,(b.width / 4) * 3, b.height / 2 + w * 4);
b.vertex(b.width/2 + w *2 ,b.height/2);
var poly = b.endShape();
poly.leftLineEnd = ArrowHead.SQUARE_ARROW_HEAD;
for(var i = 0; i < doc.strokeStyles.length; i++){
b.println(doc.strokeStyles[i].name);
}
// This is for a german localization see the console for your language
poly.strokeType = doc.strokeStyles.item("Wellenlinie");
poly.strokeWeight = 10;
// poly.strokeDashAndGap = [10,20]; // works only with "gestrichelt"
var fname = File($.fileName).parent.fsName + '/' + ($.fileName.split('/')[$.fileName.split('/').length - 1]).split('.')[0] + '.indd';
b.println(fname);
doc.save(fname, false, 'basil', true);
b.savePNG('out.png');
}
b.go();