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

AttributeError: 'arc' object has no attribute 'bbox' #15

Closed
s1291 opened this issue Nov 20, 2019 · 1 comment
Closed

AttributeError: 'arc' object has no attribute 'bbox' #15

s1291 opened this issue Nov 20, 2019 · 1 comment

Comments

@s1291
Copy link

s1291 commented Nov 20, 2019

Hello,
I am trying to run the following basic example:

from pyx import canvas, path, deco

rect = path.rect(0, 0, 5, 2)
arc = path.arc(0, 0, 1, 30, 45)
canvas = canvas.canvas()

canvas.stroke(rect, [deco.earrow.small])
canvas.stroke(arc)

canvas.writePDFfile()

When I run it:

python3 example2.py

I get the following error:

C:\Users\PC\AppData\Local\Temp\pyx>python example2.py
Traceback (most recent call last):
  File "example2.py", line 10, in <module>
    canvas.writePDFfile()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\canvas.py", line 50, in wrappedindocument
    return method(d, file, **write_kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\document.py", line 193, in writePDFfile  
    pdfwriter.PDFwriter(self, f, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\pdfwriter.py", line 329, in __init__
    catalog = PDFcatalog(document, self, registry)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\pdfwriter.py", line 143, in __init__
    self.PDFpages = PDFpages(document, writer, registry)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\pdfwriter.py", line 202, in __init__
    page = PDFpage(page, pageno, self, writer, registry)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\pdfwriter.py", line 236, in __init__
    self.PDFcontent = PDFcontent(page, writer, self.pageregistry)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\pdfwriter.py", line 268, in __init__
    page.processPDF(contentfile, awriter, acontext, registry, self.bbox)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\document.py", line 135, in processPDF
    self._process("processPDF", *args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\document.py", line 78, in _process
    bbox.set(self.canvas.bbox()) # this bbox is not accurate
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\canvas.py", line 179, in bbox
    obbox += cmd.bbox()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyx\deco.py", line 101, in bbox
    pathbbox = self.path.bbox()
AttributeError: 'arc' object has no attribute 'bbox'
@gertingold
Copy link
Contributor

path.arc is a path element. Give it as a parameter to path.path to create a path. The third line should read

arc = path.path(path.arc(0, 0, 1, 30, 45))

@s1291 s1291 closed this as completed Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants