Extension 'Pattern along Path' python script fails

Bug #486920 reported by Syllie on 2009-11-23
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Low
Alvin Penner

Bug Description

Using Inkscape 0.47pre4 on WinXP SP3

- simple horizontally straight line (2 nodes) as path for pattern
- bezier curve as path to put pattern along
- use "pattern along path" extension
- tick the "pattern is vertical" check box, to get the pattern perpendicular along the path

Set "Copies of the pattern" to single: pattern is drawn as expected
Set "Copies of the pattern" to repeated: script fails with an ZeroDivisionError error.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Traceback (most recent call last):

  File "D:\Program Files\Inkscape\share\extensions\pathalongpath.py", line 278, in <module>

    e.affect()

  File "D:\Program Files\Inkscape\share\extensions\inkex.py", line 207, in affect

    self.effect()

  File "D:\Program Files\Inkscape\share\extensions\pathalongpath.py", line 247, in effect

    NbCopies=max(1,int(round((length+self.options.space)/dx)))

ZeroDivisionError: float division

su_v (suv-lp) on 2009-11-23
tags: added: extensions-plugins
removed: extension path pattern
Syllie (eurosyl1) wrote :

Ran another test similar to the above:

If I set "Space between copies" to 1.0 the script runs fine with the repeated setting.
If I reduce the space (used 0.1) Inkscape eventually crashes with a MVC++ runtime error.

Perhaps some limitations in settings need to be calculated/set based on selected pattern for path generation?

su_v (suv-lp) wrote :

not reproduced with Inkscape 0.47pre4 and 0.46+devel r22575 on OS X 10.5.8
can you attach a sample SVG file that produces this python error?

su_v (suv-lp) wrote :

Depending on the complexity of the used pattern the result of the extension is one single path with a huge number of nodes, a file structure that often reaches the limits of Inkscapes rendering performance. OTOH it could be related to an issue as described in bug #193671 “Incorrect rendering and 16 exabyte memory usage”, most likely due to limitations of the extension system implementation and possibly Python itself?

Have you tried to use the LivePathEffect 'Pattern Along Path' instead?

su_v (suv-lp) wrote :

partly reproduced (after reading the steps more carefully ;-): pattern is straight line, path is bézier curve.
a) extension fails when pattern is vertical, repeated and 'space between copies' set to 0.0 with:

Traceback (most recent call last):
  File "Contents/Resources/extensions/pathalongpath.py", line 278, in <module>
    e.affect()
  File "/Volumes/blue/src/Inkscape/Inkscape-SVN/Inkscape.app/Contents/Resources/extensions/inkex.py", line 207, in affect
    self.effect()
  File "Contents/Resources/extensions/pathalongpath.py", line 254, in effect
    for i in range(0,NbCopies,1):
OverflowError: range() result has too many items

b) extension works with 'space between copies' set to 0.1 (see attached file)

Syllie (eurosyl1) wrote :

I can reproduce it exactly every time. And it always comes up with an ZeroDivisionError.

I do realise that this may not be the intended use for this extension because of the huge value of objects involved, I just stumbled upon it while I wanted to apply a limited number of repeats along the path, but forgot to set the spacing.

I have attached a file with paths that cause this behaviour on my system. I did a reboot of my system and started Inkscape, draw these 2 paths and ran the extension.

su_v (suv-lp) wrote :

reproduced with your drawing in Inkscape 0.46+devel r22575 on OS X 10.5.8, Python 2.6.2

1) Resetting the preferences to default values (including those for the 'Pattern along Path' extension) and applying it to your example I get the same 'ZeroDivisionError' failure.

2) increasing the number of copies
- Setting 'space between copies' to 1.0 and [x] Live Preview works as expected.
- Lowering the spacing takes increasingly longer:
  spacing 0.2: 4.5 minutes of CPU time to calculate and render
  spacing 0.1: I canceled the test after letting Inkscape run for 50 min (without crash), it had partially created and rendered the new path but seemed unable to finish.

Changed in inkscape:
status: New → Confirmed
jazzynico (jazzynico) on 2011-09-01
Changed in inkscape:
importance: Undecided → Low
status: Confirmed → Triaged
jazzynico (jazzynico) wrote :

The extensions now rejects the 0 value for 'space between copies', and no longer shows performances issues (tested with 0.1, rendered in less than a second).
But there are remaining issues when the Vertical option and a stretched mode is set:

- With Unique, stretched, the following error message shows:
Traceback (most recent call last):
  File "pathalongpath.py", line 284, in <module>
    e.affect()
  File "/usr/local/share/inkscape/extensions/inkex.py", line 227, in affect
    self.effect()
  File "pathalongpath.py", line 270, in effect
    stretch(sub,length/width,1,self.skelcomp[0])
ZeroDivisionError: float division by zero

- With Repeated, stretched, Inkscape crashed when I change the spacing value in live preview mode (with very low values, let's say 0.1, 0.2):
Program received signal SIGSEGV, Segmentation fault.
0x080e57ca in release (this=0xb4df810)
    at /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:145
145 dispose();

Backtrace attached.

jazzynico (jazzynico) wrote :
Alvin Penner (apenner) wrote :

attached is a modified version of pathalongpath.py. This one will raise a warning message instead of crashing, if the pattern width is zero when using stretch.

Alvin Penner (apenner) wrote :

committed to rev 10616

Changed in inkscape:
status: Triaged → Fix Committed
su_v (suv-lp) on 2011-09-04
Changed in inkscape:
assignee: nobody → Alvin Penner (apenner)
milestone: none → 0.49
Bryce Harrington (bryce) on 2015-02-21
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers