gotcha

Author Topic: how to automate a sequence of commands  (Read 2103 times)

September 25, 2017, 07:32:22 AM
Read 2103 times

muffintop

  • Sr. Newbie

  • Offline
  • **

  • 3
Hi, I will be doing the following sequence of transformations many times to different paths in my drawing:

-- rotate left 30 degrees
-- scale horizontal 200%
-- apply a stroke of 5px
-- apple "stroke to path" (now my path is gone, instead I have a path tracing the outline of my stroke)
-- scale horizontal 50%
-- rotate right 30 degrees

How can create some kind of shortcut to do all these things in a row?

Thank you!
  • 0.91
  • XQuartz on macOS

September 25, 2017, 01:39:51 PM
Reply #1

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
You would only need to run all of these steps exactly once for the whole drawing, using the Object -> Transform dialog with 'apply to each object separately' checked for the scaling and rotating, the Fill+Stroke dialog's Stroke style tab and the 'stroke to path' functionality.

Do you want to automate for multiple drawings?

September 25, 2017, 07:48:17 PM
Reply #2

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

I guess you must have a reason for not explaining more about your project, which I can totally respect if it just can't be shared.  But the more we know, the more likely we can offer best solution or potential solutions.  In any case, I have some questions, before I can consider how to do what you want.

First, it looks like you are rotating the path, making a couple of edits, and rotating it right back where it started.  Is the reason for doing that because it seems easier than scaling along the 330° plane or vector?

Next, why do you scale it twice?  I can't think of a reason for that.  Is it something to do with the stroke?  You should be able to just do it once (unless there's some info I don't have)?

Quote (selected)
(now my path is gone, instead I have a path tracing the outline of my stroke)

As far as I can tell, these original paths must be closed and filled, without a stroke.  (Otherwise, you wouldn't be able to add a stroke to them.) (because almost always, an open path will be already stroked)  So what you had originally was a path tracing the outline of the shape. 

When you do Stroke to Path (for your original closed paths) you not only have one path outlining your shape, you have 2.  Did you realize that?  Stroke to Path converts a single, closed path into a compound path consisting of 2 subpaths combined (inner and outer edges).  Stroke to Path converts a single open path to a single closed path.

So if your ultimate goal is a single path around a particular shape....if it's already a path, you just need to add a stroke to it.  If they are vector shapes (rectangle, ellipse, star) you just need to do Path menu > Object to Path.  Then just add the stroke.

After that (according to your steps) you would just need to scale them.  And there is a way to scale in one direction.  And as Moini says, you should be able to select them all at once, and scale them all at once.

I realize I did a lot of surmising there, so if I came to wrong conclusion, please explain more about your project or immediate goal.

Edit
To answer your question, it is possible to use scripts to perform a sequence of commands, repetitively.  You would need to know how to write the script yourself (unless someone volunteers to do it for you).  Also, Inkscape has a command line feature, which potentially could be used for this kind of thing.  But again, you need to know how to use the command line, or be willing and have time to learn.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

October 25, 2017, 11:12:01 AM
Reply #3

muffintop

  • Sr. Newbie

  • Offline
  • **

  • 3
Hi,

Sorry for the very late response.

To answer Moini, I will be doing this many times throughout different drawings, at different points in time. Whence the desirability for some kind of script.

As for what the sequence of transformations achieves, let me first restate them (and group them into three different main groups):

1. rotate left 30 degrees
2. scale horizontal 200%

3. apply a stroke of 5px
4. apply "stroke to path" (now my path is gone, instead I have a path tracing the outline of my stroke)

5. scale horizontal 50%
6. rotate right 30 degrees

Imagine for a second that #4 is removed. Then #5 undoes #2, and #6 undoes #1. So it would be like applying a stroke of 2.5px or 5px (depending on whether strokes are set to scale or not), which would a very complicated and useless way of applying a stroke!

But having #4 in there changes everything: the overall effect will be to turn the original stroke into a slightly "calligraphic" stroke (which is actually not a stroke anymore, but the fill of a path, as I point out in #4) with a width that changes slightly according to the original angle of the stroke. (Please try it in inkscape if you can't visualize it---you'll see.)

Basically, this is a way of turning an arbitrary ordinary stroke into a calligraphy-like stroke that I have found to be more reliable than the built-in inkscape path effect of same name.

Thanks!
  • 0.91
  • XQuartz on macOS

October 25, 2017, 04:20:09 PM
Reply #4

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Ok, so with lack of further info, I've performed your steps on a simple rectangular path.  See the purple rectangle in the attached screenshot st1.png, with the 6 steps.  The blue one is a shortcut to something very similar, but not quite the same.  Then st2.png is a closeup, showing what I guess you want to achieve, at the top, which is the border on 2 sides of the rectangle are wider or narrower than the other 2.  (I colored the outlines with the color of the original object, just for clarity.)

Next, I wanted to compare this with whatever you have said is not as good (a calligraphic LPE).  But I'm not finding a Calligraphic LPE.  Filter or Extension either.  Is it something that's not available in the stable release?  Or are you referring to the Calligraphy tool  :ct:?  The Calligraphy tool is meant for freehand use, ideally with a graphics tablet/pen.  So if you need a calligraphy like effect on something that's not freehand, then that's not the best tool.  Depending what your goal is, it might be possible to use Snapping with a grid or guides, in a non-freehand drawing.  But non-freehand drawing is pretty limited with Calligraphy tool.

Anyway, as I said before, you could use a script, to perform the same process repeatedly.  Or as far as I understand, it's possible to use Inkscape's command line features for this kind of thing.  But I couldn't say specifically how to do either one.  Here's a reference for the command line:  https://inkscape.org/en/doc/inkscape-man.html   But there are no options for automation on the canvas or in the interface.

Edit
Oh, but I wonder if Pattern Along Path or Powerstroke LPEs would work for you?  Or are those the LPEs you meant to say didn't work as well for you?
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann