I suppose the very first question to ask if if Inkscape or Illustrator have internal functions for this automation. If not, would something like Python make sense?

I'd like to write a small web app that would allow me to set a few variables and auto-generate a file I can import into Inkscape or Illustrator. In my most simplistic example let's try this pattern as the input...

 - - - - - 
  - - - - -
 - - - - -

I'd like to be able to define variables for

  1. Length of each dash
  2. space between it and the next dash
  3. space between lines
  4. Dash offsets (start point for the next lines dash pattern, so it is either alternate or inline)
  5. x length for file (e.g. 6cm wide)
  6. y Length for file (e.g. 6cm Tall)

Aside from the simple dash I'd like to eventually give the program a bit more complicated patterns Perhaps fonts or parametric designs that would repeat).

Can anyone suggest a good efficient way of doing this? I haven't found anything already built out there but perhaps I'm looking in the wrong places.

All suggestions welcome.

  • It's not in my wheelhouse, but you can write postscript like any other language. It is possible to write a postscript file that can be subsequently opened by either AI or Inkscape. – Scott May 24 '18 at 23:08
  • Scott, even though it may not be in your wheelhouse, your comment is a suitable answer. You should consider to post it as one. – fred_dot_u May 25 '18 at 0:06
  • 1
    Yes, Inkscape can be extended by Python extensions, see inkscape.org/en/develop/extensions . In the extension, you'd need to create the actual path data yourself. Inkscape does not have an API for drawing paths. Also, Inkscape is using SVG as its file format, writing an SVG automatically with Python without using an extension that can be called from inside Inkscape is not difficult, as SVG is a plain text XML format. – Moini May 25 '18 at 1:09
  • Welcome on GD.SE, WirelessGuy NY! If you want a web based solution see these answers on SO: stackoverflow.com/questions/20539196/… and stackoverflow.com/questions/41576879/…. See also these JavaScript framework: SVG.js, D3.js or Snap.svg. – Paolo Gibellini May 25 '18 at 13:36

Yes offcourse. Encapsulated postScript (EPS), Scalable Vector Graphics (SVG), Portable Document Format (PDF) and Drawing Exchange Format (DXF) are all just relatively simple text files. They are all trivial to make, just nontrivial to read.

Also both Illustrator and Inkscape have a script interface. Inkscape has a rather direct python connection. Illustrator also has a appleScript and COM interface which can be used using nearly any programming language including python, no problems there.

Further, many GUI interfaces like say TK and QT, but even more exist, can just export their internal drawing model as EPS, SVG or PDF (because otherwise they couldnt implement printing). Same applies to a bunch of scientific plotting tools such as matplotlib and buddies. Nearly any software that can write vectorlike data on screen can export it.

The problem is rather what to choose. can not help you there. Now since you ask i will link to a few examples that i have posted over the years:

  1. Start with this, its a good simple overwiew.
  2. Here are few good examples and alternate approaches.

There are more, possibly more topical, just seach under my answers

  • i'm intrigued. so here's a comment-question. where would i start reading about building basic pdf formatting via code? eg. like putting together some text and a table on a page? – Lucian May 25 '18 at 4:30
  • @Lucian Depends on what ecosystem/language/programs you want to use in conjunction with this. I mean you could use something like TeX, you could use reportlab, you could use a headless indesign session etc depends really on what you want to do before and after the fact. – joojaa May 25 '18 at 4:42
  • i see a text editor can also be used to generate some pdf code, but what would the limitations be when using a text editor? can i code multipage documents and link pictures/logos just by editing in notepad++? – Lucian May 25 '18 at 4:51
  • @Lucian Yes! Its just tedious to calculate the offsets. – joojaa May 25 '18 at 5:03
  • Quite generally everything a computer does you can do by hand. Its just that it may be incredibly slow. – joojaa May 25 '18 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.