Developers' discussions

158 views
Skip to first unread message

jpcaram

unread,
Feb 11, 2014, 10:39:35 AM2/11/14
to fla...@googlegroups.com
We will keep our discussions here, along the User Q&A for now.

Zhaf

unread,
Mar 4, 2014, 5:50:08 PM3/4/14
to fla...@googlegroups.com
Hi Juan Pablo.

I've found an issue with the attached gerber generated from Eagle. 
The python traceback is this:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "FlatCAM.py", line 2532, in on_success
    app_obj.new_object("gerber", name, obj_init)
  File "FlatCAM.py", line 1023, in new_object
    initialize(obj, self)
  File "FlatCAM.py", line 2528, in obj_init
    gerber_obj.create_geometry()
  File "/mnt/NasuX/Zalo/Proyectos/CNC/FlatCAM-Alpha2/camlib.py", line 820, in create_geometry
    self.do_flashes()
  File "/mnt/NasuX/Zalo/Proyectos/CNC/FlatCAM-Alpha2/camlib.py", line 766, in do_flashes
    aperture = self.apertures[flash['aperture']]
KeyError: '19'

I've managed to "workaround" this problem by adding the line "if flash['aperture'] in self.apertures:" just before the 766 line, and moving the rest of the function inside this if.

I know that this is not a fix, just a workaround, I was in a hurry and I hadn't more time to investigate the issue.

I hope you can find this information useful.
Regards!

Gonzalo.

maitest.gtl

jpcaram

unread,
Mar 4, 2014, 9:44:53 PM3/4/14
to fla...@googlegroups.com
Hi Gonzalo,

Thanks for helping out.

First of all, the parsers are missing good exception handling. This is why it silently breaks without any notice to the user. This is the first app I've written in which I have to parse complicated formats and haven't figured a very structured way to do it.

What is causing the problem specifically in your file is the use of aperture macros (AM). These are not supported (yet). I haven't come across an AM before this, and I was assuming they were very uncommon. Aperture 19 is defined in line 19 and uses macro OC8 defined in lines 7-9. It breaks when trying to use it later in the file. Can you identify what this is in your design?

For the time being I would handle the problem more gracefully (ie. ignore it) but won't support it yet. You are welcome to contribute code for that or for anything else if you want. I will try to publish a list of bugs and wished features so if you or anyone wants to help out would know what's urgently needed.

Thanks again,

JP

Zhaf

unread,
Mar 6, 2014, 4:53:08 AM3/6/14
to fla...@googlegroups.com
Hi Juan Pablo. I've investigated the issue a little bit further. The problem seems to be caused by the way Eagle exports the octagonal pads. I've found that I can modify the eagle.def file in order to modify the way Eagle exports the Gerber, so I can change the Aperture Macro to something else, like the P aperture. I know that this is not implemented in your software, but I'm going to try to implement it (as well as to improve my python skills), so we can have octagonal pads. 
I know that I can also use the C aperture, but that will be too easy, doesn't it? :)

Regards!

jpcaram

unread,
Mar 6, 2014, 9:38:56 AM3/6/14
to fla...@googlegroups.com
That would be great! Some note on that:

  • Parsing apertures is done in
    camlib.py: Gerber.aperture_parse()

  • It gets called whenever "%ADD" is found.
  • I'm trying to migrate all the parsing to use regular expressions. I defined (but not using yet)
    self.ad_re = re.compile(r'^%ADD(\d\d+)([a-zA-Z0-9]*),(.*)\*%$')

    That is in the constructor of Gerber. We would use that to first detect the aperture definition, and then we can further parse the 3rd group depending on the type detected on the 2nd group.
  • The official gerber specification is here: http://www.ucamco.com/files/downloads/file/3/the_gerber_file_format_specification.pdf
  • After parsing we need to create the geometry for flashes (I don't think we would ever encounter strokes with anything but circles). This is done in:
    Gerber.do_flashes()

    All geometry in FlatCAM is done with the Shapely library. It saves a lot of work. Read the API. There is a Polygon Class, and rotations can be done with affinity.rotate. Perhaps there is even a way to directly create an n-side polygon.
Thanks!

cuagn

unread,
Apr 1, 2014, 4:53:17 PM4/1/14
to fla...@googlegroups.com
Hi Juan Pablo,

I always have curiosity for things I don't understand.
I could remain only a user of FlatCAM, however I try for a couple of days (last week-end) to go through the sources.

I face some difficulties and you may probably give me some answers.

0/ I'm running W7 64 bits with Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
For compatibility reasons (as I've understood (?) after googling a lot)

1/ glade version
I've installed version 3.14.2 and I can load FlatCam.ui without any problem
After installing pygi-aio-3.10.2-win32_rev18-setup.exe (for gi.repository)  a version 3.15.0 (in french)
Using 3.15 and loading FlatCam.ui I get an error "...Unable to get GladeWidget for internal child vbox"
May be (probably)  the installation of glade is not fully OK. That's strange.
Q : which version are you using ? coming from ?

2/ I've been able (is it true?)  to find and install most of the modules imported. Stop at shapely !

Here are the versions installed:
Using setup.py install
docutils-0.11
python-dateutil-2.2
Shapely-1.3.0
simplejson-3.3.3
six-1.6.1

Using the installer

pyparsing-2.0.1.win32-py2.7.exe
pygi-aio-3.10.2-win32_rev18-setup.exe
setuptools-0.6c11.win32-py2.7.exe
matplotlib-1.3.1.win32-py2.7.exe
numpy-1.8.1-win32-superpack-python2.7.exe

shapely-1.3.0 is not working. The installer (same version) failed during installation and I've "setup.py install" it
A dll issue...I wasn't able to solve. (attached)

Q: could you provide some info about the required  modules (version, url) ? It will be helpful to have the official toolkit.

Even  if the searches have been a very good training for me.

Cheers

Marc
Error.txt

jpcaram

unread,
Apr 2, 2014, 11:11:16 AM4/2/14
to fla...@googlegroups.com
Hi Marc,
Find my responses inline with your questions below.

 
0/ I'm running W7 64 bits with Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
For compatibility reasons (as I've understood (?) after googling a lot)

Most libraries only support the 32-bit version of Python. 64 bits is not necessarily better/faster and 32 bits will work on 32-bit machines and 64-bit  machines, while you cannot say the same about 64-bit programs.
 
 
1/ glade version
I've installed version 3.14.2 and I can load FlatCam.ui without any problem
After installing pygi-aio-3.10.2-win32_rev18-setup.exe (for gi.repository)  a version 3.15.0 (in french)
Using 3.15 and loading FlatCam.ui I get an error "...Unable to get GladeWidget for internal child vbox"
May be (probably)  the installation of glade is not fully OK. That's strange.
Q : which version are you using ? coming from ?

I'm using 3.14.2. But I think  pygi-aio-3.10.2-win32_rev18-setup.exe installs another version of Glade (3.16...). See this link http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar for the list of things included in that packages. I would use whatever comes with that .exe.


2/ I've been able (is it true?)  to find and install most of the modules imported. Stop at shapely !

Here are the versions installed:
Using setup.py install
docutils-0.11
python-dateutil-2.2
Shapely-1.3.0
simplejson-3.3.3
six-1.6.1

Using the installer

pyparsing-2.0.1.win32-py2.7.exe
pygi-aio-3.10.2-win32_rev18-setup.exe
setuptools-0.6c11.win32-py2.7.exe
matplotlib-1.3.1.win32-py2.7.exe
numpy-1.8.1-win32-superpack-python2.7.exe

I think you got confused here. There is no setup.py. I'm assuming you are trying to get FlatCAM-Alpha4.zip running. For that you need Python 2.7.6, Numpy, Matplotlib, Shapely and PyGI. If you install WinPython, then most of that is already installed for you. See chapter 2.2 in the Manual
 

shapely-1.3.0 is not working. The installer (same version) failed during installation and I've "setup.py install" it
A dll issue...I wasn't able to solve. (attached)

By looking at the error message, it looks like you are missing the binary part of Shapely. I installed from this package:  Shapely-1.3.0.win32-py2.7.exe
 

Q: could you provide some info about the required  modules (version, url) ? It will be helpful to have the official toolkit.

The "Official toolkit" would be that which is described in section 2.2 of the manual. Just those 3 Windows binary installers. Again, using Winpython (WinPython 2.7 32 bit) simplifies things.
 
I hope this helps. And thanks for being interested in looking into the code.

Cheers,

JP

cuagn

unread,
Apr 8, 2014, 3:17:00 AM4/8/14
to fla...@googlegroups.com
Hi JC

Thank you for your detailed answer.

My fault was to start from an already installed Python and to try to add the missing modules.
Following your guidelines is quite better.
I wipe out all previous Python, and it was quite direct.

Marc
Reply all
Reply to author
Forward
0 new messages