creating extension - need to call intersect

Post questions on how to use or achieve an effect in Inkscape.
Neon22
Posts: 11
Joined: Mon Mar 07, 2011 10:31 am

creating extension - need to call intersect

Postby Neon22 » Mon Mar 07, 2011 11:05 am

I am having a blast creating some extensions.
I wonder is there a way to call union or intersect on a pair of closed paths I have created. (stored in lists)
Something like:

Code: Select all

for x in range(len(xblocks)):
        for y in range(len(yblocks)):
               piece = intersect(xblocks[x], yblocks[y])


Thanks...

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: creating extension - need to call intersect

Postby brynn » Mon Mar 07, 2011 10:57 pm

Hi Neon22,
Image
Welcome to InkscapeForum!

I'm sorry I can't answer your question, but just wanted to say welcome :D

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: creating extension - need to call intersect

Postby RobA » Tue Mar 08, 2011 5:38 am

I don't believe any of the built in functions are exposed through an API in that manner.

Plugins work directly against the xml dom and aren't really running "inside" inkscape. There are a few helper python libraries installed but I don't think I've seen one for doing intersections.

You may be able to shell out to another instance of inkscape and have it perform the intersection, but that is beyond me.

-Rob A>

Neon22
Posts: 11
Joined: Mon Mar 07, 2011 10:31 am

Re: creating extension - need to call intersect

Postby Neon22 » Wed Mar 09, 2011 8:00 am

it looks like its not possible to do this :?
Only a very limited interface between inkscape and python exists. It appears to only support the manipulation of grouping, styles, svg paths, and import/export of new formats.

There is a fork of inkscape which has a python binding here: https://code.launchpad.net/~thinker-codemud/inkscape/pybind
This appears to exist primarily for adding new UI elements to Inkscape. (interesting project to make UIs in svg for html5 for mobile apps.)

But there appears to be no consensus on the devel maillist about supporting a scripting language binding. :(

So I guess i will have to implement my own intersection code :( which is a shame because the internal one is excellent.
I have found this intersection code from 2003:
http://www.kevlindev.com/gui/math/intersection/index.htm
and I'll submit an extension if I can get it working.

(kind of defeats the purpose though....)

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: creating extension - need to call intersect

Postby ~suv » Wed Mar 09, 2011 9:27 am

Neon22 wrote:But there appears to be no consensus on the devel maillist about supporting a scripting language binding. :(

I don't follow your argument: The dbus scripting API exists in inkscape trunk (a merged GSoC project) and can be used with any scripting language (via dbus). It does offer access to internal functions, AFAIU. Why would your extension have to be able to add dialogs and menus to inkscape just do do intersections?

Neon22
Posts: 11
Joined: Mon Mar 07, 2011 10:31 am

Re: creating extension - need to call intersect

Postby Neon22 » Wed Mar 09, 2011 9:50 pm

AFAIU dbus does not work on Windows. (but I see they intend to work on that at some point - alas the latest release makes no mention of it in the release notes)
I don't need dialogs - I was commenting on the purpose of the existing fork.

I have searched but obviously not well enough and can find no examples, or direct mention, of how a python extension might use dbus to get at the internals...?
Can you point me to where I might start looking to see how to proceed?
I've started trolling through the source

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: creating extension - need to call intersect

Postby ~suv » Wed Mar 09, 2011 10:06 pm

Neon22 wrote:AFAIU dbus does not work on Windows.
Yes, it's not yet fully 'cross-platform' as far as I know - that's why it is in the developement branch only, and not enabled when building with the default configure options (not even on linux/unix-based platforms).

Neon22 wrote:Can you point me to where I might start looking to see how to proceed?
Not with regard to using it on Windows, sorry (nor with regard to further details about using dbus and the dbus-based scripting API itself on supported platforms: I'm not a coding myself, and haven't succeeded yet to get to launch current dbus daemons (in a 'launch-on-demand' way suited to be used in the packaged, relocatable Inkscape application bundle) on Mac OS X - the platform I use to build and test stable and unstable inkscape versions).

Possibly you can get some additional information from the 'inkboardng' project (which aims to rewrite the old 'Whiteboard' plugin based on the new dbus scripting API). AFAICT there are build scripts for Windows available (at least when browsing the code). You might consider getting into contact with Mat, the developer of 'inkboardng'?
Last edited by ~suv on Wed Mar 09, 2011 10:30 pm, edited 1 time in total.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: creating extension - need to call intersect

Postby ~suv » Wed Mar 09, 2011 10:28 pm

Some additional links from the inkscape-devel mailing list archives about the initial GSoC project (since the original documention is no longer online, and the docs in the source tree require various tools to be built, and aren't online available in the HTML version either):



Return to “Help with using Inkscape”