Skip to content

Instantly share code, notes, and snippets.

@fwextensions
Created February 12, 2013 01:01
Show Gist options
  • Save fwextensions/4759119 to your computer and use it in GitHub Desktop.
Save fwextensions/4759119 to your computer and use it in GitHub Desktop.
How to create a new layer at the top of the stack, add objects to it, and lock it.
var dom = fw.getDocumentDOM(),
currentLayerIndex = dom.currentLayerNum,
newLayerIndex;
dom.addNewLayer(null, false);
// currentLayerNum is set to the newly added layer
newLayerIndex = dom.currentLayerNum;
// put the new layer before the last layer. note that this won't work
// if the Web layer has sublayers.
dom.reorderLayer(newLayerIndex, dom.layers.length - 1, 0, 1);
// add an object to the new layer and lock it
dom.addNewRectangle({ left: 0, top: 0, right: 100, bottom: 100 }, 0);
dom.setLayerLocked(-1, -1, true, false);
// focus the previously active layer
dom.currentLayerNum = currentLayerIndex;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment