Copy link to clipboard
Copied
Is it possible to use JSFL to select the Line tool from the Tools panel, and then set the "Stroke size" parameter (or any of those parameters in the Properties panel) to a certain value?
Copy link to clipboard
Copied
See getCustomStroke()/setCustomStroke() in the JSFL docs.
Copy link to clipboard
Copied
Beautiful! Thanks. i swear i had already tried that. 🙂
While we're talking, i'm having trouble doing another thing... (perhaps i should make a new post?)
i draw some stuff on a layer. i want this to happen:
i can't get it to work, because i can't figure out how to indicate the most recently drawn-on layer. My script will work if i click on the layer in the timeline, but i don't want to have to do that. And document.selectAll() grabs everything on all layers. i tried a goofy workaround, by locking all other layers before i selectAll(), but even that doesn't work unless i've physically clicked to select the current layer in the timeline:
var dom = an.getDocumentDOM();
var tl = dom.getTimeline();
var layer = tl.layers[tl.currentLayer]; // perhaps a useless declaration, because locking is a method of Timeline, not Layer
// Lock all other layers:
tl.setLayerProperty("locked", true, "others");
If i draw on a layer and run this script, it locks ALL layers (instead of all OTHER layers) and i don't understand why. It won't work unless i first click to select the layer in the timeline.
- Ryan
Copy link to clipboard
Copied
Hi,
I can't understand what you want to achieve with the code, but I would say that the method
timeline.setLayerProperty() works with "selected" layers, not the "current" one.
So, If you want to lock all layers, with the exceptance of one (or more), you need to select these layers:
var timeline = fl.getDocumentDOM().getTimeline();
timeline.setSelectedLayers(3);
timeline.setLayerProperty("locked", true, "others" );
Now, the parameters make sense:
"selected" - changes the selected layers
"others" - changes "unselected" layers
"all" - changes all layers
Copy link to clipboard
Copied
What i'd like to achieve is precisely this:
1. Draw some lines on a layer.
2. Use a keyboard shortcut to run a JSFL script.
3. All of the artwork (ONLY on the layer i was just drawing on) is automatically selected.
4. Convert lines to fills.
5. The layer is set to 50% transparency.
Copy link to clipboard
Copied
OK, I see 🙂
Save the following code as a command, assign it a shortcut key and press the button each time after finish your drawing on the layer.
I think, it should work as you expect.
var doc = fl.getDocumentDOM();
var tml = doc.getTimeline();
var myLayer = tml.layers[ tml.currentLayer ];
var myFrame = myLayer.frames[ tml.currentFrame ];
// Deselect all
// After that iterate through the elements in the current frame of the current layer
doc.selectNone()
for( var i = 0; i < myFrame.elements.length; i++ ){
myFrame.elements[ i ].selected = true;
}
// Convert lines to fills.
doc.convertLinesToFills();
// The layer is set to 50% transparency.
myLayer.transparent = true;
myLayer.alpha = 50;