Writing an extension for a new object type
Hi,
I see that one can write so called "effect" extensions which are available through the effects menu. But is it also possible to write an extension that allows the creation of a new object type at a position where the user clicks?
For example, an extension that allows me to click on a new button in the tools menu. When I then click somewhere in the image, a script is run which creates a predefined object at the clicked position.
Thanks! Nathan
I've written a number of extensions that create predefined objects as part of creating the symbol sets for orientering maps in Inkscape. These are accessed through the 'extensions' menu. These extensions create the symbol at the centre of the current window. I don't believe that it would be possible to select the position of the symbol by clicking after the extension has been selected, but stand to be corrected by others that have greater knowledge (and if it is possible, then I would be interested in how this can be achieved). After the object has been created, it can be dragged into place, rotated, etc., as any other Inkscape object.
My extensions can be downloaded at: https://sourceforge.net/projects/o-scape/files/
Jon
----- Original Message ----- From: "Nathan Hüsken" <nathan.huesken@...2820...> To: "Inkscape Mailinglist" inkscape-user@lists.sourceforge.net Sent: Thursday, March 17, 2011 4:14 PM Subject: [Inkscape-user] Writing an extension for a new object type
Hi,
I see that one can write so called "effect" extensions which are available through the effects menu. But is it also possible to write an extension that allows the creation of a new object type at a position where the user clicks?
For example, an extension that allows me to click on a new button in the tools menu. When I then click somewhere in the image, a script is run which creates a predefined object at the clicked position.
Thanks! Nathan
Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Hey,
Thanks for you link, it is helpful as it is an example.
But since I want to place lots of objects at positions where the user clicks, this approach is not really an option.
On 03/17/2011 06:43 PM, Jon wrote:
I've written a number of extensions that create predefined objects as part of creating the symbol sets for orientering maps in Inkscape. These are accessed through the 'extensions' menu. These extensions create the symbol at the centre of the current window. I don't believe that it would be possible to select the position of the symbol by clicking after the extension has been selected, but stand to be corrected by others that have greater knowledge (and if it is possible, then I would be interested in how this can be achieved). After the object has been created, it can be dragged into place, rotated, etc., as any other Inkscape object.
My extensions can be downloaded at: https://sourceforge.net/projects/o-scape/files/
Jon
----- Original Message ----- From: "Nathan Hüsken" <nathan.huesken@...2820...> To: "Inkscape Mailinglist" inkscape-user@lists.sourceforge.net Sent: Thursday, March 17, 2011 4:14 PM Subject: [Inkscape-user] Writing an extension for a new object type
Hi,
I see that one can write so called "effect" extensions which are available through the effects menu. But is it also possible to write an extension that allows the creation of a new object type at a position where the user clicks?
For example, an extension that allows me to click on a new button in the tools menu. When I then click somewhere in the image, a script is run which creates a predefined object at the clicked position.
Thanks! Nathan
Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
I do not know of any way of reading the mouse position from inside a Python extension, or trapping an event like a mouse click; however... it might be worthwhile to consider the following workaround. - ask the user to draw a small rectangle (or anything) at the desired position - make sure this is still selected when you load the extension - from inside the Python extension, detect the selected object, and overwrite it with your custom object, removing the original rectangle completely
You may be able to re-use some of the ideas present in the "Modify Path" submenu, for example, perspective.py, which modifies an existing object.
hth, Alvin Penner
Hi Nathan
This is easily sorted, but not from within Python. To do what you want, use an extension or a separate inkscape drawing to generate / hold the symbols. Once you have created or copied the symbol into your current drawing, drag the object and press the space bar at each location that you want a copy of the symbol. This is a lot quicker than running an extension multiple times and will give the same result. Look at Copying, Pasting and Deleting Objects page here: http://tavmjong.free.fr/INKSCAPE/MANUAL_v16/html/Copy.html .
Hope this helps. Jon
----- Original Message ----- From: "Nathan Hüsken" <nathan.huesken@...2820...> To: inkscape-user@lists.sourceforge.net Sent: Friday, March 18, 2011 1:03 PM Subject: Re: [Inkscape-user] Writing an extension for a new object type
Hey,
Thanks for you link, it is helpful as it is an example.
But since I want to place lots of objects at positions where the user clicks, this approach is not really an option.
On 03/17/2011 06:43 PM, Jon wrote:
I've written a number of extensions that create predefined objects as part of creating the symbol sets for orientering maps in Inkscape. These are accessed through the 'extensions' menu. These extensions create the symbol at the centre of the current window. I don't believe that it would be possible to select the position of the symbol by clicking after the extension has been selected, but stand to be corrected by others that have greater knowledge (and if it is possible, then I would be interested in how this can be achieved). After the object has been created, it can be dragged into place, rotated, etc., as any other Inkscape object.
My extensions can be downloaded at: https://sourceforge.net/projects/o-scape/files/
Jon
----- Original Message ----- From: "Nathan Hüsken" <nathan.huesken@...2820...> To: "Inkscape Mailinglist" inkscape-user@lists.sourceforge.net Sent: Thursday, March 17, 2011 4:14 PM Subject: [Inkscape-user] Writing an extension for a new object type
Hi,
I see that one can write so called "effect" extensions which are available through the effects menu. But is it also possible to write an extension that allows the creation of a new object type at a position where the user clicks?
For example, an extension that allows me to click on a new button in the tools menu. When I then click somewhere in the image, a script is run which creates a predefined object at the clicked position.
Thanks! Nathan
Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
participants (3)
-
Alvin Penner
-
Jon
-
Nathan Hüsken