<input>:1: DeprecationWarning: invalid escape sequence \p <input>:1: DeprecationWarning: invalid escape sequence \p Traceback (most recent call last): File "/usr/lib/python3.9/code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 282, in get_or_create node = self.findone(xpath) File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 344, in findone el_list = self.xpath(xpath) File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 336, in xpath return super(BaseElement, self).xpath(pattern, namespaces=namespaces) File "src/lxml/etree.pyx", line 1597, in lxml.etree._Element.xpath File "src/lxml/xpath.pxi", line 305, in lxml.etree.XPathElementEvaluator.__call__ File "src/lxml/xpath.pxi", line 225, in lxml.etree._XPathEvaluatorBase._handle_result lxml.etree.XPathEvalError: Invalid expression
Can someone point me in the right direction?
In essence, I want to inject these blocks for every page into the main svg element:
If I understand it, my xpath expression is not right. That makes perfect sense as I don't know how to write the xpath for a newly to be injected element.
Now it seems to want to create the element, since it didn't find it. But now the "nodeclass=None" isn't accepted.
Traceback (most recent call last): File "/usr/lib/python3.9/code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 284, in get_or_create node = nodeclass() TypeError: 'NoneType' object is not callable
for i, page in enumerate(self.svg.namedview.get_pages()):
self.msg("Page number {}: x: {} y: {} width: {} height: {}".format(i+1, page.get("x"), page.get("y"), page.get("width"), page.get("height")))
Hi,
will inkex support to add pages programmatically?
What would be the best way to add the <inkscape:page ... >element to the file?
I think the easiest approach would be to use the get_or_create() command, but I'm getting an error message. This is what I'm trying:
self.svg.get_or_create("//inkscape:page")
(the following is the error message I get when trying to perform the command in the terminal:
This results in the following error:
<input>:1: DeprecationWarning: invalid escape sequence \p
<input>:1: DeprecationWarning: invalid escape sequence \p
Traceback (most recent call last):
File "/usr/lib/python3.9/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 282, in get_or_create
node = self.findone(xpath)
File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 344, in findone
el_list = self.xpath(xpath)
File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 336, in xpath
return super(BaseElement, self).xpath(pattern, namespaces=namespaces)
File "src/lxml/etree.pyx", line 1597, in lxml.etree._Element.xpath
File "src/lxml/xpath.pxi", line 305, in lxml.etree.XPathElementEvaluator.__call__
File "src/lxml/xpath.pxi", line 225, in lxml.etree._XPathEvaluatorBase._handle_result
lxml.etree.XPathEvalError: Invalid expression
Can someone point me in the right direction?
In essence, I want to inject these blocks for every page into the main svg element:
<inkscape:page
x="0"
y="0"
width="210"
height="297"
id="page2306" />
If I understand it, my xpath expression is not right. That makes perfect sense as I don't know how to write the xpath for a newly to be injected element.
Nevermind... it had to be forward slash :p
This actually found the (already existing) pages... didn't get me to actually create a page though.
But this took me to my next issue...
This is my next try:
Now it seems to want to create the element, since it didn't find it. But now the "nodeclass=None" isn't accepted.
Traceback (most recent call last):
File "/usr/lib/python3.9/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/home/jurgen/.config/inkscape/extensions/lib/python3.9/site-packages/inkex/elements/_base.py", line 284, in get_or_create
node = nodeclass()
TypeError: 'NoneType' object is not callable
For future reference: multipage support is added to Inkex. No more need to manually fiddle with XML.
These are some example commands:
To add a page: