Menu

#58 [geda PCB]board outline layer

All
open
nobody
None
2024-09-06
2017-08-01
Anonymous
No

Hi, thanks for the PCB-to-FreeCAD importer!
While importing a PCB from gEDA, I found some bugs in formats/geda.py, which I'd like to share with you:

Layer headers with () instead of []

In the function getLayerByNumber, the regex assumes that a layer is defined by:

Layer[1, name]
(
    <layer objects>
)

However, gEDA PCB currently exports the following:

Layer(1, "name")
(
    <layer objects>
)

I fixed this by modifying the regex to:

layer = re.search('^Layer\s*[\[\(]{0} .+?[\]\)]\n\(\n([^\)].+?\n)?\)\n'.format(layerNumber), self.projektBRD, re.DOTALL|re.MULTILINE).groups()[0]

notice the [[(] and [])] groups, which accept either () or [].

Board outline not in a fixed layer

In the function getPCB, the code assumes that the board outline is defined in layer 7. This is incorrect. According to http://wiki.geda-project.org/geda:pcb_tips#how_do_i_make_a_board_outline_to_go_with_my_gerbers_to_the_board_maker the outline should be defined on a (randomly chosen) layer, which becomes the 'outline' layer by simply renaming it to outline (case sensitive).
To fix this, I added a function getLayerByName, which is very similar to getLayerByNumber:

    def getLayerByName(self, layerName):
        '''Function returns whole layer section'''
        try:
            layer = re.search('^Layer\s*[\[\)][0-9]+ \"{0}\"[\]\)]\n\(\n([^\)].+?\n)?\)\n'.format(layerName), self.projektBRD, re.DOTALL|re.MULTILINE).groups()[0]
            if layer:
                return layer
            else:
                return ''
        except:
            return ''

In getPCB, I replaced the two calls to getLayerByNumber(7) by getLayerByName('outline').

getAnnotations

The function getAnnotations simply searches all Text objects in the PCB file, but does not take the location of the texts (top/bottom) into account. I decided to leave this as it is for now...

Discussion

  • Anonymous

    Anonymous - 2017-08-01

    Oops, typo in getLayerByName: the function should be:

    def getLayerByName(self, layerName):
            '''Function returns whole layer section'''
            try:
                layer = re.search('^Layer\s*[\[\(][0-9]+ \"{0}\"[\]\)]\n\(\n([^\)].+?\n)?\)\n'.format(layerName), self.projektBRD, re.DOTALL|re.MULTILINE).groups()[0]
                if layer:
                    return layer
                else:
                    return ''
            except:
                return ''
    
     
    • Anonymous

      Anonymous - 2024-09-06

      Модные заметки по подбору модных луков на каждый день.
      Заметки профессионалов, новости, все показы и шоу.
      https://rftimes.ru/news/2024-08-14-7-samyh-kultovyh-veshchey-ot-balenciaga

       
  • Mariusz

    Mariusz - 2017-08-02

    Hi,
    ad 1 - this is problematic in geda, if I remember sometimes there is even 4 different structures to define the same object, agr :). Will be fixed.
    ad 2 - somethin new, will be fixed.
    ad 3 - at the moment annotations do not work anywhere correctly :). Will be fixed.

    I will implement changes in new version. Thanks for feedback.

     

Anonymous
Anonymous

Add attachments
Cancel