Hi Martin,

I'm using 0.92 at the moment. New extensions API, is there already some documentation about that? On one of the Inkscape forums I also read something about C++ extensions being supported in the (near) future?

Back to the question, I'm not sure why I'm getting that FutureWarning. I assumed that the last argument of inkex.etree.SubElement is a node (formatted as a dictionary), and that self.selected[self.options.ids[0]] gives me such an object. Apparently, one of these assumptions is not correct?

Best,
Pieter

On Fri, 2 Nov 2018 at 02:13, <doctormo@...400...> wrote:
Hi Pieter,

Are you using the old inkscape 0.92 extensions or the new inkscape 1.0
extensions API (in trunk and gitlab.com/inkscape/extentions/)

The basics are right, you need to duplicate the object and any children
(for instance in case of text). Transforms can be applied ontop of any
existing transformation.

Best Regards, Martin Owens

On Fri, 2018-11-02 at 00:11 +0100, Pieter Barendrecht wrote:
> Hi all,
>
> Given a selected object (e.g. firstObject =
> self.selected[self.options.ids[0]]) in a Python extension, how can I
> duplicate it? I've checked a couple of code snippets (e.g.
> pathscatter.py as well as some online content) and stumbled upon
> copy.deepcopy(...) and append() for layers, but I don't have it
> working properly yet.
>
> Usually, I add a new object (e.g. a path) using
>
> newObject = inkex.etree.SubElement(self.current_layer,
> inkex.addNS('path','svg'), pathAttribs),
>
> where pathAttribs has been defined before. Can I add the duplicated
> object in a similar way? When I substitute 'pathAttribs' with
> 'firstObject' or a deepcopy() of it, I get the following
> FutureWarning —
>
> FutureWarning: The behavior of this method will change in future
> versions. Use specific 'len(elem)' or 'elem is not None' test
> instead.
>   newObject = inkex.etree.SubElement(self.current_layer,
> inkex.addNS('path','svg'), firstObject)
>
> As an exercise I'm trying to write an extension that generates a
> circular array of a selected (path) object. The approach could be to
> first duplicate the object and subsequently transform it (i.e. rotate
> and possibly translate) using simpletransform.composeTransform () and
> simpletransform.applyTransformToPath().
>
> As a follow-up question, is it possible to clone an object from
> within a Python extension? With 'clone' I mean the operation that's
> available in Inkscape through Edit → Clone → Create Clone.
>
> Thanks! Best,
> Pieter
>
> _______________________________________________
> Inkscape-devel mailing list
> Inkscape-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/inkscape-devel