Inkscape.org
Beyond the Basics Automate shape shifting
  1. #1
    meetdilip meetdilip @meetdilip

    Hi, I was able to create shapes with dots using Inkscape. This is for a font project and there are a no. of such shapes. Is there any method to apply " shapes to dots " to around 300 such SVGs ? Otherwise, it is applying them individually.

     

    Screenshot From 2021 03 20 10 05 21
  2. #2
    Tyler Durden Tyler Durden @TylerDurden

    Hi, it's not clear if you have many shapes or many svg files... please provide us with more details.

  3. #3
    meetdilip meetdilip @meetdilip

    SVG A = one single pattern

    SVG F1 to F300 = Unicode characters turned to paths using - Object to Path and Ungroup

    I can open the Patten SVG, copy it, open the F1 SVG and then use " Intersection " to get the shapes as in the image in the original post. Thick shape to sieve shape.

    Now I need to do the same with  F2 to F300 or find some way to automate the whole process. I hope it is clear to you now. Thanks.

     

     

  4. #4
    inklinea inklinea @inklinea⛰️

    Does the width and height of the final svg have to be the same across all svg's ?  Or is it going to be cropped to the bounding box of the resulting shape ? 

  5. #5
    meetdilip meetdilip @meetdilip
    *

    Thanks @inklinea  I am using the typography template which comes with Inkscape. So yes, the canvas would be 1000x1000px.

    I hope that is a requirement, right ? In order to keep the alignment of glyphs when we use them as fonts.

  6. #6
    inklinea inklinea @inklinea⛰️
    *

    Okay this is not a very elegant solution.  Works on Linux for multiple files.

    If you make a folder ( any name ) with sub folders called 'done' and 'temp'

    Put the attached dotsPath.svg in a folder above the folder you made

    This script will do what you want.

    for f in *; do 

    test -f $f || continue

    cp $f temp

    sed -i '/<\/svg>/d' temp/$f

    sed -n -e '/<g/,/<\/g>/p' ../dotsPath.svg | cat >> temp/$f

    echo '</svg>' >> temp/$f

    inkscape --batch-process --actions="select-all;SelectionIntersect;export-filename:done/$f;export-do;" temp/$f

    done

     

    Examples attached

     

    Two
    One
    Two
    One
    Dotspath
  7. #7
    meetdilip meetdilip @meetdilip

    Awesome!! This will be more than enough. I will try this as soon as possible. Thanks a lot :)

  8. #8
    meetdilip meetdilip @meetdilip
    *

    Hi, I got this error when I tried with script name saved as power.py

     

    $ python3 power.py
      File "power.py", line 1
        for f in *; do
                 ^
    SyntaxError: invalid syntax

     

    Screenshot From 2021 03 24 14 58 01
  9. #9
    inklinea inklinea @inklinea⛰️

    It's a shell script, bash, does not require python.

    If you are using a standard linux distribution such as ubuntu. 

    open a text editor, paste in the text, save as myScript.sh ( any filename with .sh extension ) 

    $ chmod +x myScript.sh 

    To make it executable.

  10. #10
    meetdilip meetdilip @meetdilip
    *

    Thanks for your time. I really appreciate it

    Sadly, I got into another error

     

    PS : yes, using 20.04

     

     

    Error
  11. #11
    inklinea inklinea @inklinea⛰️
    😇

    If you arrange the folders and contents as shown in the attached png image.

    cd into the folder called 'svgs'

    from inside the svgs folder type ../myScript.sh

    Should do what you want.

    I did not know how familiar with linux you were. 

    I made a couple more examples using that setup.

     

    Goodbye
    Hello
    Scripttree
  12. #12
    meetdilip meetdilip @meetdilip

    Thanks. I know I am messing up something. I haven't tried anything like this before. So nice of you to explain. :)

  13. #13
    meetdilip meetdilip @meetdilip

    I never thought it will so much easy to execute. It worked perfectly.

     

    Inside the " done " folder, I was able to find the 2 product SVGs and the dotsPath.svg as attached below.

    Now I need to rework on my SVGs so that it aligns perfectly. But I am more than happy now becauseI have a standard conversion method available.

     

     

    Screenshot From 2021 03 24 20 40 36
  14. #14
    inklinea inklinea @inklinea⛰️

    If you have a Typography canvas with a single object in it. You should not have to rework all the svg files.

    If you close Inkscape, it remembers the 'relative to' option you last used in the align and distribute panel. It will use that setting for any command line alignments on single objects.

    I have attached an image with the 'relative to' set to 'page'

    Try using the following command line on the svg attached called 'wonkyText.svg' it produces an output file called aligned.svg

    inkscape --batch-process --actions="EditSelectAllInAllLayers;AlignVerticalHorizontalCenter;export-filename:aligned.svg;export-do;" wonkyText.svg 

     

     

    Wonkytext
    2021 03 24 17 10
  15. #15
    meetdilip meetdilip @meetdilip
    *

    My old files are a mess. I worked on it a couple of months ago. I am not sure about the alignment myself. It would be easier to create one by one properly aligned in the typography canvas. There are around 200+ of them. I am not sure whether we can rip them off a .sfd file ( Font Forge ) or a Unicode PDF.

     

    If I understand correctly, the last reply is about using the alignment of the previous SVG in other SVG files, right ? It would be great. I will check my files ( old work files were drawn in default canvas ) and update here. Thanks.