Exemplo n.º 1
0
 def parse_components(self, components):
     """ Extract a component library. """
     for library_id, component in components.items():
         name = component.get('name')
         comp = Component(name)
         # Get attributes
         for key, value in component.get('attributes', []).items():
             comp.add_attribute(key, value)
         for symbol_json in component.get('symbols', []):
             symbol = self.parse_symbol(symbol_json)
             comp.add_symbol(symbol)
         for footprint_json in component.get('footprints', []):
             footprint = self.parse_footprint(footprint_json)
             comp.add_footprint(footprint)
         self.design.add_component(library_id, comp)
Exemplo n.º 2
0
 def parse_components(self, components):
     """ Extract a component library. """
     for library_id, component in components.items():
         name = component.get('name')
         comp = Component(name)
         # Get attributes
         for key, value in component.get('attributes', []).items():
             comp.add_attribute(key, value)
         for symbol_json in component.get('symbols', []):
             symbol = self.parse_symbol(symbol_json)
             comp.add_symbol(symbol)
         for footprint_json in component.get('footprints', []):
             footprint = self.parse_footprint(footprint_json)
             comp.add_footprint(footprint)
         self.design.add_component(library_id, comp)
Exemplo n.º 3
0
    def _convert_library(self, struct):
        """ Convert library """
        for image in struct.library.image:
            component = Component(image.image_id)
            self.design.add_component(image.image_id, component)
            fpt = Footprint()
            body = FBody()
            component.add_footprint(fpt)
            fpt.add_body(body)
            for pad in image.pin:
                body.add_pad(Pad(pad.pad_id, self.to_pixels(pad.vertex), self.to_pixels(pad.vertex)))
                for padstack in struct.library.padstack:
                    if padstack.padstack_id == pad.padstack_id:
                        shapes = [shape.shape for shape in padstack.shape]
                        for shape in self._convert_shapes(shapes, self.to_pixels(pad.vertex)):
                            body.add_shape(shape)
                        break

            for outline in image.outline:
                for shape in self._convert_shapes([outline.shape]):
                    body.add_shape(shape)