Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes sometimes don't have the is_visible attribute #141

Closed
bchardin opened this issue Sep 27, 2023 · 1 comment · Fixed by #142
Closed

Nodes sometimes don't have the is_visible attribute #141

bchardin opened this issue Sep 27, 2023 · 1 comment · Fixed by #142
Labels

Comments

@bchardin
Copy link

Describe the bug

svg2tikz fails to generate a valid output when the is_visible attribute does not exist.

Setup:

  • Mode: shell tool
  • SVG2TikZ version: 1.2 cc6cc42
  • OS version: Debian 11
  • Inkscape version: 1.0.2
  • inkex version: 1.3.0

To Reproduce

Input SVG (generated with Inkscape):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg8"
   inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
   sodipodi:docname="sample.svg">
  <defs
     id="defs2" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.35"
     inkscape:cx="400"
     inkscape:cy="560"
     inkscape:document-units="mm"
     inkscape:current-layer="layer1"
     inkscape:document-rotation="0"
     showgrid="false"
     inkscape:window-width="1533"
     inkscape:window-height="974"
     inkscape:window-x="26"
     inkscape:window-y="23"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <circle
       style="fill:#ff0000;fill-rule:evenodd;stroke-width:0.264583"
       id="path1917"
       cx="93.138641"
       cy="127.18604"
       r="37.044617" />
  </g>
</svg>

Command used:

svg2tikz sample.svg

Output result:

Traceback (most recent call last):
  File "/home/bch/.local/bin/svg2tikz", line 8, in <module>
    sys.exit(main_cmdline())
  File "/home/bch/svg2tikz/svg2tikz/tikz_export.py", line 1421, in main_cmdline
    effect.convert(**kwargs)
  File "/home/bch/svg2tikz/svg2tikz/tikz_export.py", line 1376, in convert
    self.run()
  File "/home/bch/svg2tikz/svg2tikz/tikz_export.py", line 1349, in run
    self.save_raw(self.effect())
  File "/home/bch/svg2tikz/svg2tikz/tikz_export.py", line 1267, in effect
    string = self._output_group(nodes)
  File "/home/bch/svg2tikz/svg2tikz/tikz_export.py", line 1186, in _output_group
    goptions = self.style_to_tz(node) + self.trans_to_tz(node)
  File "/home/bch/svg2tikz/svg2tikz/tikz_export.py", line 772, in style_to_tz
    if style.get("display") == "none" or not node.is_visible:
  File "/home/bch/.local/lib/python3.9/site-packages/inkex/elements/_base.py", line 147, in __getattr__
    raise AttributeError(f"Can't find attribute {self.typename}.{name}")
AttributeError: Can't find attribute Metadata.is_visible

Expected behavior

I believe entities without the is_visible attribute could be considered visible instead of raising an error.

@ldevillez
Copy link
Collaborator

Hello @bchardin,
Thanks for finding this bug :)

@ldevillez ldevillez linked a pull request Sep 29, 2023 that will close this issue
8 tasks
@ldevillez ldevillez added the bug label Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants