jfdeclercq.com Welcome Photos About Blog
Feedback Contact Twitter Facebook LinkedIn Downloads Lowas.be

- >> March 2024 >> - Show 10, 25, 50, All News - Expand All, Compact All, 1024 chars

My 2 jArchi scripts

Last year I wrote 2 jArchi scrips. Those scripts allow to add functionality to the Archimate toolkit. (The Archimate toolkit is a a tool which allow Business and IT Architects to model the Business/Enterprise/IT architectutes using the Archimate notation.)

The scripts are tagged #jarchi on Github. (See also github/jfdeclercq)

I always need to search for my own scripts so I post them here also.

Script to add a note to a diagram:

/*
 * New Archi Script
 */
console.log("AddNote Started !");
//var date = new Date();
//console.log(date.toString());
//var note = archimateView.createObject("note", 10, 200, -1, -1);
//note.setText("This is a note.\n\nHello World!");
//var note = visualObject.createObject("note", 10, 200, -1, -1);


// Get the first view in the current selection
var view = selection.filter("archimate-diagram-model").first();
// Get current date
var currentDate = new Date();
// Create a new note and set its text
var note = view.createObject("note", 10, 10, 300, -1);
note.text = view.name + "\n" + currentDate.toString() +"\n" + "Jean-Francois Declercq";
note.fillColor = "#e2e2be";
console.log("Note added to " + view.name);

Script to export a diagram as picture with the name of the view as proposed image name:

//Export View as image (PNG)  with date and diagram name in filename.

// Get the first view in the model
//var view = $("view").first();
var view = selection.filter("archimate-diagram-model").first();
// Get the Base64 bytes of the view in PNG format. Can use "PNG", "BMP", "JPG" or "GIF"
// Options are scale (1 - 4) and margin (pixel value)
var bytes = $.model.renderViewAsBase64(view, "JPG", {scale: 1, margin: 20});

var date = new Date();


// Ask for a file name
var fileName = window.promptSaveFile( { title: "Save View", filterExtensions: [ "*.jpg" ], fileName: ""+ date.toISOString().replace(":","").replace("T","-").slice(0,15)+ "-" + view.name + ".jpg" } );
if(fileName) {
    // Write to file
    $.fs.writeFile(fileName, bytes, "BASE64");
}

|| >> March 2024 >>