Objects ("patterns") along path - pathscatter extension
Hi,
background: I want to model some room with rows of chairs, not necessarily along straight lines however. Furthermore, I want to be able to access each chair from python, in order to change appearance depending on status in a reservation system.
Thus, I have been looking into an "create objects along path" functionality, and found the pathscatter ("Generate from Path/Pattern along Path") extension, plus some "path effect" which I could not get to work and did not find any documentation on. I also had a lot of problems with the pathscatter extension, which I would like to discuss with you and possibly provide fixes for at least some of them. (I am an experienced programmer, in particular with python, but not very familiar with inkscapes code or even GUI yet.)
First, my impression was that the extension is slow (I think there's a lot of potential for improvements, since it looks like a straightforward but not very efficient python implementation) and not very well integrated into the GUI, which is probably a typical problem with scripted extensions (I have experience with Gimp's script-fu stuff). For instance: 1. The menu has no accelerators, which makes it inconvenient to start without using the mouse. 2. It has an apply and a close button, but the apply button does not close the dialog, although the only sensible (actually: possible) action after it is close, since it modifies the selection, and the dialog is modal. 3. The dialog is modal, but does not check whether its preconditions (two objects selected) are fulfilled, so you end up making settings, getting an error message on "apply", need to close, fix the selection, and re-open it again (suffering from 1 again). 4. Also, there does not seem to be any good documentation or even help within the program (for instance: icons, tooltips or "whats this" texts, ...); the best information I found was the python comments at the top of pathscatter.py, which should probably be at least put up on some wiki page.
Speaking of preconditions, it took me more than an hour to understand how to use the extension, simply because I tried it only with a rectangle as pattern. The results were incredibly... wrong. That's because the extension seems to work only with paths (that is - circles seem to work) - this could surely be improved either by a) allowing rectangles, which should be possible at least in the "snake" mode, or by b) automatically converting other objects into paths.
Actually, my plan would be to implement both a+b, since I then realized that with just b) (which is probably the easiest to implement) I have yet another problem: in the "repeated" mode, I am still getting only a single path as result, which contains several path components. For my use case, I really need separate objects, in order to be able to differently style the chairs.
I have some basic coding questions, which I will put into a separate posting.
Hi again,
looking at pathscatter.py, I got some questions concerning the programming of (path-modifying) python extensions:
1) Is it possible to use more or less the same code in a standalone script? And/or what is your preferred way of developing extensions, i.e. reload the module etc.?
2) The code seems to use many helper functions from modules in the "extensions" directory, for example in the "bezmisc" module. I was surprised to see that they are all based on pure Python. Wouldn't it be more convenient and efficient to have (more of) inkscapes C routines available? (For instance, there must already be code for beziers, for computing point/slope at t, converting to parameter form etc.)
3) Along the same lines: The code (e.g. in bezmisc) does not seem to make use of any special classes, but handle point-by-point as coordinate pairs. AFAICS it would be much more efficient to at least make use of numpy, e.g. for polygonal coordinate data.
4) Is it possible to query the length of a path? Actually, I have searched for this functionality already in the GUI itself, but could not find it. Did I overlook something? For pathscatter, it could be useful to preview the number of copies that would fit along the path, for instance.
-----Original Message----- From: Hans Meine [mailto:hans_meine@...240...] Sent: Thursday, January 07, 2010 21:24 To: inkscape-devel@lists.sourceforge.net Subject: [Inkscape-devel] Programming python extensions (not onlypathscatter)
Hi again,
looking at pathscatter.py, I got some questions concerning the programming of (path-modifying) python extensions:
- Is it possible to use more or less the same code in a
standalone script? And/or what is your preferred way of developing extensions, i.e. reload the module etc.?
- The code seems to use many helper functions from modules
in the "extensions" directory, for example in the "bezmisc" module. I was surprised to see that they are all based on pure Python. Wouldn't it be more convenient and efficient to have (more of) inkscapes C routines available? (For instance, there must already be code for beziers, for computing point/slope at t, converting to parameter form etc.)
- Along the same lines: The code (e.g. in bezmisc) does not
seem to make use of any special classes, but handle point-by-point as coordinate pairs. AFAICS it would be much more efficient to at least make use of numpy, e.g. for polygonal coordinate data.
- Is it possible to query the length of a path? Actually, I
have searched for this functionality already in the GUI itself, but could not find it. Did I overlook something? For pathscatter, it could be useful to preview the number of copies that would fit along the path, for instance.
You could try using lib2geom's python library, although it is still in alpha phase. http://wiki.inkscape.org/wiki/index.php/Lib2geom_py2geom Inkscape uses lib2geom to do a lot of the path operations. Because py2geom is still in alpha, we have not converted any extension to use it. But I am very sure that the lib2geom team would welcome anybody using py2geom warmly, and will try to give support (including modifying/expanding py2geom).
Cheers, Johan
On Donnerstag 07 Januar 2010, Hans Meine wrote:
First, my impression was that the extension is slow (I think there's a lot of potential for improvements, since it looks like a straightforward but not very efficient python implementation) and not very well integrated into the GUI, [...]
I forgot to say that this extension does not seem to perform a very special task (which would justify its extension status), but could be useful for many purposes. Thus, I assume there are plans to have this in the core, similar to the text-along-path functionality, with full live preview and update when modifying the path etc.? (As soon as someone gets the job done..)
Or would "path effects" help, which looked quite promising, but I could not find out how to use them (e.g. specify the pattern)? In that case, I am sorry if I overlooked some documentation.
Otherwise, would it be a good intermediate step to improve the python extension before introducing it as a core feature? The latter would certainly not be a job for me, while I could contribute to the former, as time permits.
2010/1/7 Hans Meine <hans_meine@...240...>:
Or would "path effects" help, which looked quite promising, but I could not find out how to use them (e.g. specify the pattern)? In that case, I am sorry if I overlooked some documentation.
I think "Pattern along Path" is what you want. First select your pattern and press Ctrl+C. Then select the path, go to Object->Path Effects->Path Effects Editor, and apply the Pattern along Path effect. Click the paste icon near the pattern parameter. It should work now.
Regards, Krzysztof
Thanks, Krzysztof!
On Donnerstag 07 Januar 2010, Krzysztof Kosiński wrote:
I think "Pattern along Path" is what you want. First select your pattern and press Ctrl+C. Then select the path, go to Object->Path Effects->Path Effects Editor, and apply the Pattern along Path effect. Click the paste icon near the pattern parameter. It should work now.
Right; the settings were not self-explaining to me. http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Paths-LivePathEffects.html helped a lot (I ignored it before, since it wasn't on inkscape.org).
Now, apart from having the same problem as the extension that one may not paste/link rectangles directly, the LPE works perfectly and beautifully fast and flexible! :-)
However, for my use case, it also suffers from another problem I discussed before for the extension, namely that it produces a single path. I need separate objects, to be able to set different fill styles.
Obviously, producing a series of objects does not fit into the beautiful LPE framework, so I was thinking about other possibilities. What about a means (extension?) to separate an objects' path components into single path objects? My feeling is that that could be useful for others, too, and I did not find it too unlikely to be already possible, but I could not find it. (I hope I do not overlook again something already available.)
However, for my use case, it also suffers from another problem I discussed before for the extension, namely that it produces a single path. I need separate objects, to be able to set different fill styles.
That is the point of path effects. It keeps a path as a path.
If you want to create a number of different paths, use the pattern along path extension then perform a Path->Break Apart to separate the individual paths so they can be coloured individually.
-Rob A>
On 1/8/10, Hans Meine wrote:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Paths-LivePathEffects.html helped a lot (I ignored it before, since it wasn't on inkscape.org).
Doh. Inkscape.org is not the only and true God's messenger, you know? ;)
However, for my use case, it also suffers from another problem I discussed before for the extension, namely that it produces a single path. I need separate objects, to be able to set different fill styles.
We "just" need a complete overhaul of our effects system so that anything we do to objects could be tweaked later. Much like filter effects in Illustrator/Photoshop.
Alexandre
Hi!
Path scatter was coded very fast as someone asked for it while ùi had no time to spend on it, so the code might definitely be improved. The difference between pattern along path and path scatter is that former bends the pattern whil the latter places it undeformed at the desired place.
IMO, this should be replaced by some lpe that randomly repeats the "pattern" over the area and or the boundary of an object. I wrote a little toy in 2geom that chooses radom places in a given area.
As about getting separate objects as output, one workaround would be to first duplicate your object as many times as needed, group them, and apply the lpe to the group. I didn't test it right now, but it should do it (althought some bugs might remain about lpe and groups). Of course this is not very satisfying because you need to know how many copies to create in advance... :-(
Cheers, JF.
2010/1/9 Alexandre Prokoudine <alexandre.prokoudine@...400...>
On 1/8/10, Hans Meine wrote:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Paths-LivePathEffects.html helped a lot (I ignored it before, since it wasn't on inkscape.org).
Doh. Inkscape.org is not the only and true God's messenger, you know? ;)
However, for my use case, it also suffers from another problem I
discussed
before for the extension, namely that it produces a single path. I need separate objects, to be able to set different fill styles.
We "just" need a complete overhaul of our effects system so that anything we do to objects could be tweaked later. Much like filter effects in Illustrator/Photoshop.
Alexandre
This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On 1/9/10, jf barraud wrote:
As about getting separate objects as output, one workaround would be to first duplicate your object as many times as needed, group them, and apply the lpe to the group. I didn't test it right now, but it should do it
Um, no. It doesn't work :) And for cases like subpaths interpolation it won't work in principle.
Alexandre
On 1/7/10, Hans Meine wrote:
plus some "path effect" which I could not get to work
Care to elaborate? :)
and did not find any documentation on.
This is interesting, because it's documented in:
1. Release notes 2. Tav's book on Inkscape (online) 3. FLOSS Manuals book (online)
Alexandre
participants (6)
-
unknown@example.com
-
Alexandre Prokoudine
-
Hans Meine
-
jf barraud
-
Krzysztof Kosiński
-
Rob Antonishen