• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Make artboards ranges depending on dynamic set lengths

Advocate ,
Jan 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

Hi all,

 

im trying to get artboards number ranges depending on length of a dynamic set length. 
Im using different logo types (max 4 in length) to get all the artboard numbers of that set.
Each set starts with the logo type as name and has more data in the artboardname.

 

for example i use 3 logo types; logo, logotype, logomark. Each set has 6 artboards with a total of 8.

I can of course make 4 different function according to the logotype and then make the ranges.

But is it possible to do this all dynamic in a short function?

So in this example the artboards are like this
example of 3 logotypes with a total of 18 artboardsexample of 3 logotypes with a total of 18 artboards

Ive found a piece of code on stackexchange to divide that into 3 ranges. Which is like this, changed it to work in illustrator

 

 

 

 

var logtypesLen = logotypes.length;
    // https://math.stackexchange.com/questions/385514/algorithm-to-separate-an-array-of-numbers-into-low-medium-and-high-ranges
    // list.sort();
    // part1 = list[0 : n/3];
    // part2 = list[n/3 : 2*n/3];
    // part3 = list[2*n/3 : n];
    var abs = docRef.artboards;
    var n = abs.length;
    // var part1 = abs[0] +" "+abs[n/3-1];
    // var part2 = abs[n/3] +" "+abs[2*n/3-1];
    // var part3 = abs[2*n/3] +" "+abs[n-1];
    var part1 = (0) +" "+(n/3-1);
    var part2 = (n/3)+" "+(2*n/3-1);
    var part3 = (2*n/3) +" "+(n-1);

 

 

 

 

I could make this so it would work in logo types set of 4, but i feel that uses more code than needed. Since i also need to have function for a set of 1 and a set of 2.

Here is example of how it now works. I made this logo packer CEP panel. When i change the margins and have logotypes set to all, all work nice. The small logo info imprint gets placed neatly around all artboards. But when i use a single artboard, it gets misplaced. This is because im not getting the proper range of artboards.

Ps dont mind the alerts, this is to check my example code i pastedPs dont mind the alerts, this is to check my example code i pasted

The imprint basically says per row logotype and then per each row has either; full color, inverted, black, white & possible extra colors. This info is placed as the small imprint in fuchia.

If i can get the correct artboard range. Than when i edit a single artboard, i only need address that row of imprint data.

 

I was also thinking of just updating everything no matter what. Perhaps that is a better choice without making it to complicated.

 

Im trying to explain my need as best as possible. Hope you understand

TOPICS
Scripting , Tools

Views

155

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jan 17, 2024 Jan 17, 2024

I don't understand what you are trying to do (probably my fault), but from the stackexchange question and answer, I presume you're trying to divide an array of length "l" into sets of a number "n".  If so, I think this function should do what you want

var l = 6;  // length of array
var n = 3;  // number of sets

// sets is an array of sets, 
// each set being an array of two indices, 
// a start and an end
var sets = divideArray(l, n);
alert(sets);

function divideArray(l, n) {
    if (n > l) {
 
...

Votes

Translate

Translate
Adobe
Guide ,
Jan 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

I don't understand what you are trying to do (probably my fault), but from the stackexchange question and answer, I presume you're trying to divide an array of length "l" into sets of a number "n".  If so, I think this function should do what you want

var l = 6;  // length of array
var n = 3;  // number of sets

// sets is an array of sets, 
// each set being an array of two indices, 
// a start and an end
var sets = divideArray(l, n);
alert(sets);

function divideArray(l, n) {
    if (n > l) {
        alert("n cannot be >l.");
        return;
    }
    var sets = [];
    for (var i = 0; i < n; i++) {
        var start = Math.floor((i * l) / n);
        var end = Math.floor(((i + 1) * l) / n) - 1;
        sets.push([start, end]);
    }
    return sets;
}

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 17, 2024 Jan 17, 2024

Copy link to clipboard

Copied

Intried my best to explain, that's why I added an image and a video. Indeed l is an array as well and n represents the number of artboards. Var l is added as a prefix to each artboard. So each can have number of artboards, mostly they should be the same amount per set.

Though the number of o can change, it can b1 to t can be 2,3 or 4.

 

Currently I made a decision to bypass this. I now simply add the info imprint again no matter what. The imprint updates when I adjust the margins per artboard. The issue was that it would not get the Pröpper set depending on which logotype was used, which is var l.

Does that make sense?

 

Edit

Well I flipped the n and l, so lnis total of artboards and n are the logotypes. This is a variable array with min 1 and max 4 items.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

@femkeblanco 

 

This works like a charm! I keep hold of this code. For now i moved away from this idea. Since my solution know doesnt need to look at what artboard it is per set.
Thanks for the help and the code you shared, much appreciated!!!

I made a test with 18 artboards and 3 sets. I correctly return 3 sets; "0-5", "6-11", "12-17"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 20, 2024 Jan 20, 2024

Copy link to clipboard

Copied

LATEST

You're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines