Jump to content

Affinity Designer: create sequence of numbers


Recommended Posts

1 hour ago, GraphicDesigner said:

Is there a way to create a sequence of a sequence of numbers in Designer? I want to label a custom diagram I'm making. ...

In Affinity, I don't think so. AFAIK there isn't any option for creating sequences of numbers or the like.

But you can instead use any scripting language to output some range of number values (it's easy done via loops) as text and then copy that text over into Affinity. Here is a plain simple python example ...

def createSeq(seqstart,seqend): 
  
    # Testing if range seqstart and seqend are equal 
    if (seqstart == seqend): 
        return seqend 
  
    else: 
  
        # loop to print successors until seqend is reached. 
        while(seqstart < seqend+1 ): 
              
            print(seqstart, end = ' ')
            seqstart += 1
      
# Driver Code 
# Setup two vars to build our range
seqstart, seqend = -3, 3

# Call and run our above little createSeq(...) function
createSeq(seqstart, seqend)

... which when executed outputs ...

Quote

> python3 createseq.py                                                                                                                                                                
-3 -2 -1 0 1 2 3

If you change the above "print(seqstart, end = ' ')" into just "print(seqstart)" it will print the given sequence range numbers each on seperate lines (so with newlines) ...

Quote

> python3 createseq.py                                                                                                                                                              
-3                                                                                                                                                                                    
-2                                                                                                                                                                                    
-1                                                                                                                                                                                    
0                                                                                                                                                                                     
1                                                                                                                                                                                     
2                                                                                                                                                                                     
3     

If you modify the increment statement ("seqstart += 1") inside the while loop to other values, you can influence the number distance output of the range/sequence.

NOTE: You can for example also let sequence output be generated in SVG format instead then, so you can afterwards import all sequence numbers at once via a SVG file, in order to have every sequence number as a single positionable number-text layer in Affinity.

Generally there are a bunch of possibilities to get/generate number sequences that way and you can basically use any scripting language for such tasks.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

Here is a quick take in Java (thus platform portable), which uses just a plain for-loop in oder to generate a range of output numbers. The loop uses an increment setting for stepping, so you can flexible define number ranges [start, step, end].

public static List<Integer> getNumbersInRange(int start, int step, int end) {
    List<Integer> result = new ArrayList<>();
    for (int i = start; i <= end; i=i+step) {
        result.add(i);
    }
    return result;
}

Further it allows to place any given string inbetween the numbers as a number delimiter, as also the left and right range boundaries as a string if  wanted. So it's easy to generated needed number ranges.

Quote

> java SeqGenerator                                                                                                                                                                   
You will now have to enter three numbers and strings for the range setup ...                                                                                                          
                                                                                                                                                                                      
Enter the range *start* number value: -100                                                                                                                                            
Enter the range *step*  number value: 10                                                                                                                                              
Enter the range  *end*  number value: 50                                                                                                                                              
                                                                                                                                                                                      
Enter a string or use blanks as a number separator:                                                                                                                                   
Enter a left range delimiter string or blanks: min                                                                                                                                    
Enter a right range delimiter string or blanks:   max                                                                                                                                 
                                                                                                                                                                                      
min  -100  -90  -80  -70  -60  -50  -40  -30  -20  -10  0  10  20  30  40  50  max

> java SeqGenerator                                                                                                                                                                   
You will now have to enter three numbers and strings for the range setup ...                                                                                                          
                                                                                                                                                                                      
Enter the range *start* number value: 0                                                                                                                                               
Enter the range *step*  number value: 5                                                                                                                                               
Enter the range  *end*  number value: 100                                                                                                                                             
                                                                                                                                                                                      
Enter a string or use blanks as a number separator:  -                                                                                                                                
Enter a left range delimiter string or blanks: (                                                                                                                                      
Enter a right range delimiter string or blanks:  )                                                                                                                                    
                                                                                                                                                                                      
( 0 - 5 - 10 - 15 - 20 - 25 - 30 - 35 - 40 - 45 - 50 - 55 - 60 - 65 - 70 - 75 - 80 - 85 - 90 - 95 - 100 )

If you have a need for that let me know, then I can provide you the Java code and a precompiled class file or jar file. Though you would need to have at least a Java 8 SE runtime environment installed to execute it.

 

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

  • 2 years later...

I know this is a very old thread, but I just came across it while looking for a similar solution and thought I would suggest another way to do it in case it comes useful to someone.

Another quick way to create the numbers sequence mentioned above if you don't want to use scripting is by using Microsoft Excel.

Just type the first 2-3 blocks (vertically or horizontally) of how you want the sequence to start (3,2), then select the blocks and drag the selection rectangle from the side and it will fill the rest of the blocks automatically with the numbers according to the same sequence (3,2,1,0,-1,-2...)

Then copy the text into Affinity Designer. 

Screenshot 2022-11-29 150653.jpg

Link to comment
Share on other sites

Thanks for that LondonSquirrel, I really should spend more time with the Terminal application. seq means "print a sequence from x to y". That will save me some time scripting something really simple. Now how soon until I forget this?

Mac Pro (Late 2013) Mac OS 12.7.6 
Affinity Designer 2.5.5 | Affinity Photo 2.5.5 | Affinity Publisher 2.5.5 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.