Skip to content

Instantly share code, notes, and snippets.

@adig
Last active October 12, 2023 02:46
Show Gist options
  • Select an option

  • Save adig/e570578e34e6c0e29fa5b5bca21b83f3 to your computer and use it in GitHub Desktop.

Select an option

Save adig/e570578e34e6c0e29fa5b5bca21b83f3 to your computer and use it in GitHub Desktop.
let x = 0, y = 0, col = 0, maxCols = 20, rowHeight = 0, width = 0, height = 0;
MQAPI.workspace.startOpBatch();
MQAPI.workspace.sidebar.view.get('all_stencils')
.map((stencil) => {
return stencil.get('name');
})
.forEach(function(stencilName) {
let stencil = MQAPI.canvasManager.addStencil({
name: stencilName,
x,
y
});
x += stencil.width + 10;
rowHeight = Math.max(rowHeight, stencil.height);
width = Math.max(x, width);
height = y + rowHeight;
col += 1;
if(col > maxCols) {
col = 0;
x = 0;
y += rowHeight + 10;
}
});
MQAPI.workspace.activePage.setPageSize({
width,
height
});
MQAPI.workspace.endOpBatch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment