-
Notifications
You must be signed in to change notification settings - Fork 38
Model Functions
Phil Beauvoir edited this page Jan 13, 2020
·
12 revisions
- .create()
- .load()
- .isAllowedRelationship()
- .renderViewAsBase64()
- .isModelLoaded()
- .getLoadedModels()
Create a new model:
var newModel = $.model.create("Test Model");
newModel.setAsCurrent(); // Set it to be the current model ("model")
Load a model from file:
var myModel = $.model.load("/path/test.archimate");
myModel.setAsCurrent(); // Set it to be the current model ("model")
model.openInUI(); // Open it in the UI (Models Tree)
Return true if a relationship type is allowed between two concepts
$.model.isAllowedRelationship(relationship-type, source-concept-type, target-concept-type)
Example:
var isAllowed = $.model.isAllowedRelationship("assignment-relationship", "business-actor", "business-role")
Get the image data encoded as Base64 from a View.
.renderViewAsBase64(view, format, options...)
- view - reference to a view
- format - one of "PNG", "BMP", "JPG" or "GIF"
- options
- scale = integer value of 1 to 4
- margin = integer value of pixels
var view = ...; // A view reference
var bytes = $.model.renderViewAsBase64(view, "PNG"); // Get bytes
// Embed in a HTML string
var html = "<html><body><p>" + view.name + "</p>" + "<img src=\"data:image/png;base64," + bytes + "\"></body></html>";
var view = ...; // A view reference
var bytes = $.model.renderViewAsBase64(view, "PNG", {scale: 1, margin: 20}); // Get bytes
// Write to file
$.fs.writeFile("path/view.png", bytes, "BASE64");
Return true if a given model is loaded in the Models Tree. Does not apply when used from the Command Line.
$.model.isModelLoaded(model)
Example:
var model = ...; // A model reference
var loadedinUI = $.model.isModelLoaded(model)
Returns a list of models that are loaded in the Models Tree. Does not apply when used from the Command Line.
$.model.getLoadedModels()
Example:
var loadedModelsList = $.model.getLoadedModels();
If you value and use Archi please consider making a donation. Thanks!