Empty page template broken; python problems
Hi,
I have discovered that "Empty Page" template creation is quite broken. The 'viewBox' is always the same, regardless of which page size and orientation are selected. It appears that "empty_page.py" is just pulling in the "default.svg" file and changing the <svg> 'width' and 'height' attributes without changing the 'viewBox' to match. I can patch this but am having trouble with setting attributes within sodipodi:namedview to match.
For example, the following code attempts to simply change the 'id' of sodipoid:namedview:
namedview = root.find(inkex.addNS('namedview', 'sodipodi')) inkex.debug( namedview.get("id") ) namedview.set("id", "NewID" ) inkex.debug( namedview.get("id") )
The debug output shows that the 'id' attribute is changed but if I then examine <namedview> with the XML editor it doesn't show the change.
Any clues as to what is going on would be greatly appreciated.
Tav
Hi, not sure how come you need to change the id, is the default
<sodipodi:namedview id="base">
not acceptable?
Alvin
-- View this message in context: http://inkscape.13.x6.nabble.com/Empty-page-template-broken-python-problems-... Sent from the Inkscape - Dev mailing list archive at Nabble.com.
On Tue, 2014-10-07 at 06:51 -0700, alvinpenner wrote:
Hi, not sure how come you need to change the id, is the default
<sodipodi:namedview id="base">
not acceptable?
That is not the issue... that was simply a test. I want to change other things such as inkscape:document-units, inkscape:cx, etc.
sorry, I did not say it very clearly. What I meant is that id's are special, Inkscape may be deliberately overwriting it, perhaps try some other attribute instead.
Alvin
-- View this message in context: http://inkscape.13.x6.nabble.com/Empty-page-template-broken-python-problems-... Sent from the Inkscape - Dev mailing list archive at Nabble.com.
On Tue, 2014-10-07 at 07:09 -0700, alvinpenner wrote:
sorry, I did not say it very clearly. What I meant is that id's are special, Inkscape may be deliberately overwriting it, perhaps try some other attribute instead.
I've tried other attributes with the same result. I can override the root (<svg>) id.
On 2014-10-07 15:56 , Tavmjong Bah wrote:
On Tue, 2014-10-07 at 06:51 -0700, alvinpenner wrote:
Hi, not sure how come you need to change the id, is the default
<sodipodi:namedview id="base">
not acceptable?
That is not the issue... that was simply a test. I want to change other things such as inkscape:document-units, inkscape:cx, etc.
Changing namedview attributes seems to fail for others too - see e.g. comment here: https://code.google.com/p/eggbotcode/source/browse/trunk/inkscape_contribute...
Changing current layer via namedview attribute has been implemented (not without regressions): https://bugs.launchpad.net/inkscape/+bug/789122 but I can't find other reports about modifying namedview attributes via extension scripts in the bug tracker. I vaguley recall having seen questions about this before (apart from the eggbot maze extension) - a quick web search e.g. turns up this one: http://www.inkscapeforum.com/viewtopic.php?f=34&t=16505 (no reply or solution though)
Regards, V
On Tue, 2014-10-07 at 17:09 +0200, su_v wrote:
On 2014-10-07 15:56 , Tavmjong Bah wrote:
On Tue, 2014-10-07 at 06:51 -0700, alvinpenner wrote:
Hi, not sure how come you need to change the id, is the default
<sodipodi:namedview id="base">
not acceptable?
That is not the issue... that was simply a test. I want to change other things such as inkscape:document-units, inkscape:cx, etc.
Changing namedview attributes seems to fail for others too - see e.g. comment here: https://code.google.com/p/eggbotcode/source/browse/trunk/inkscape_contribute...
Changing current layer via namedview attribute has been implemented (not without regressions): https://bugs.launchpad.net/inkscape/+bug/789122 but I can't find other reports about modifying namedview attributes via extension scripts in the bug tracker. I vaguley recall having seen questions about this before (apart from the eggbot maze extension) - a quick web search e.g. turns up this one: http://www.inkscapeforum.com/viewtopic.php?f=34&t=16505 (no reply or solution though)
I've reached my maximum limit of debugging frustration. Deleting sodipodi:namedview as is done for all other elements results in crashes at various places. The code to skip deleting namedview predates the move to bzr. Why is sodipodi:namedview special?
For the moment, I changed the code to simply copy the attributes in namedview.
Code checked into 'experimental' branch. I also updated empty_page.py to generate proper 'viewBox' attributes as well as 'inkscape:cx' and 'inkscape:cy'.
Tav
On Tue, 2014-10-07 at 14:40 +0200, Tavmjong Bah wrote:
namedview = root.find(inkex.addNS('namedview', 'sodipodi')) inkex.debug( namedview.get("id") ) namedview.set("id", "NewID" ) inkex.debug( namedview.get("id") )
Just to break this down, you're doing:
root.find("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd%7Dnamedview")
Try the same disfiguration in the set command:
namedview.set(inkex.addNS('id', 'sodipodi'), "NewID")
You should also be able to do instead:
document.getNamedView()
But looking at inkex and a few examples in the code, I don't really like the addNS design. It's making lots of ugly code. (adds to list)
Martin,
For example, the following code attempts to simply change the 'id' of sodipoid:namedview:
namedview = root.find(inkex.addNS('namedview', 'sodipodi')) inkex.debug( namedview.get("id") ) namedview.set("id", "NewID" ) inkex.debug( namedview.get("id") )
The debug output shows that the 'id' attribute is changed but if I then examine <namedview> with the XML editor it doesn't show the change.
Any clues as to what is going on would be greatly appreciated.
Hi Tav, not sure but could be missing the ?equivalent to effect.affect()
Regards, Jabier.
participants (5)
-
alvinpenner
-
Jabiertxo Arraiza Cenoz
-
Martin Owens
-
su_v
-
Tavmjong Bah