Closed 1Ghasthunter1 closed 3 years ago
Yeah, that's a weird bug. You can totally just multiply it with imul but it crashes in the other form.
svg[-1] *= "translate(100,100)"
I think I always short handed added those values that I never bothered to check the create a new object form of the multiplication there.
At issue is that the copy()
for Group
objects of which SVG
is a type thereof, does not properly initialize itself fully. It exits that code with a return without calling the SVGElement init which calls the by property and by value initializations for the subclasses. Of specific importance it sets the group's transform
value which is really helpful when you want to multiply it out. Without it set it tries to multiply by None, which is notably fails in that error.
It's a genuine bug, I'll have it fixed shortly. Just need to make sure I'm doing everything right and crossing all ts and dotting the js, so as to not introduce additional bugs.
Ah, that makes a lot of sense. Take your time; no rush. It's not worth messing anything else up.
It's just checking through some code and making sure it's not going anywhere weird, and writing a test case and making sure it passes all the current test cases. It makes it fairly safe. 1.4.12 is done. Publishing soon.
Fixed and published.
The code is in maintenance mode so bug fixes are a priority and usually rather small and dealt with rapidly.
Likely any big future changes would be in #87 rewrite, since that would be able to capture a lot of things this library misses. So, it's kinda a priority to fix things well and fast. Just took some double checking and authoring some test code.
First off, thanks for all of the documentation; it's apparent to me you guys have put hours in to write that. So, before reading, if I made a usage error, I apologize beforehand, but I've been stuck trying to translate the entire contents of an SVG file.
Before I go into the issue, keep in mind my main goal is to apply a series of transformations, like translations or rotations, to the entire SVG file. I start by importing the package as
from svgelements import *
Then, I import my svg file with
svg = SVG.parse("path.svg")
Upon typing
svg
in the python command line, I get the full object which confirms (at least I think) my file was imported successfully:It only made sense for me to do something like
Group(svg[-1])
, which worked, and I would get:Then, I would attempt to translate this svg:
Group(svg[-1]) * Matrix.translate(100, 100)
And the exception comes back as
AttributeError: 'NoneType' object has no attribute '__imatmul__'
Any help would be greatly appreciated, and thanks for all of the work you guys have done!