Copy link to clipboard
Copied
I have some confusion. When the object I select is a drawing object or shape, I can use the following code to add a stroke to it.
fl.getDocumentDOM().selection[0].x += 0;
fl.getDocumentDOM().setStrokeSize(10);
This code cannot take effect on the selected group or symbol.
Using the history function I get code like this:
an.getDocumentDOM().setStroke('#000000', 10, 'solid');
Repeated operations found that this code only takes effect on the drawing object union.
Back to my question:
If the selected object is a group or symbol, the following code cannot stroke it.
customStrokeWidth = 10;
if (customStrokeWidth) {
var doc = fl.getDocumentDOM();
var selection = doc.selection[0];
myStroke(selection, customStrokeWidth);
}
function myStroke(element, strokeWidth) {
if (element.elementType === "group") {
var elements = element.getElements();
for (var i = 0; i < elements.length; i++) {
var nestedElement = elements[i];
myStroke(nestedElement, strokeWidth);
}
} else {
doc.selection = [element];
doc.setStrokeSize(strokeWidth);
}
}​
Did I miss something?
Yes, the setStrokeSize() method sets the stroke size of the selected object,
but only if the object is either a raw shape or a union.
Symbols, on the other hand, cannot have their strokes directly modified since they are not raw shapes. To achieve this, you must enter to the symbol's timeline via the method enterEditMode() and iterate through its objects, adjusting their stroke sizes individually.
Similarly, modifying the stroke of a group is not possible because groups are not raw shapes or unions
...Copy link to clipboard
Copied
Yes, the setStrokeSize() method sets the stroke size of the selected object,
but only if the object is either a raw shape or a union.
Symbols, on the other hand, cannot have their strokes directly modified since they are not raw shapes. To achieve this, you must enter to the symbol's timeline via the method enterEditMode() and iterate through its objects, adjusting their stroke sizes individually.
Similarly, modifying the stroke of a group is not possible because groups are not raw shapes or unions.
Unfortunately, you cannot access their timeline for adjustments since it does not exist for groups.
Copy link to clipboard
Copied
I see, this is really a headache. In my recent project, I needed to add strokes to a lot of materials without strokes, so I thought of this.
Copy link to clipboard
Copied
it's just more coding and if you really have a lot of things to edit can still be very efficient.