-
Notifications
You must be signed in to change notification settings - Fork 176
kicad_mod_generator
Idea would be generating models using python as base language. The whole framework/library should be made in a way where scripting a component is as simple as possible without too much general/structural/reppetive code for each component script.
Current project members:
- @pointhi (irc: pointhi) (footprint generator)
- @iromero91 (irc: cyborg_ar) (3d model generator)
The script should be able to be called like:
./demo_footprint.py spec1.csv spec2.csv spec3.yml -v dir=Demo.pretty
But also inside python (where I have to think of an implementation ^^)
using an argparse similar api, which is build in a way to support different types of input (csv, yml, call inside python script) looks like a good idea.
from kicad_mod_generator import parser, KicadFootprint
class MyFootprint(KicadFootprint):
def __init__(self):
KicadFootprint.__init__(self)
def write_footprint(self, format):
return None
def write_3d_model(self, filename):
return None
parser = KicadModParser(MyFootprint)
parser.description = "some example footprint"
parser.set_arguments([{'arg':'name', type:str},
{'arg':'datasheet', type:str}])
parser.add_argument('dimension_A', type=int) # other way of defining arguments, which would require more coding
parser.add_argument('dimension_B', type=int)
parser.add_argument('dimension_C', type=int)
if __name__ == '__main__':
parser.run()
class KicadFootprint(object):
'''
Handles generation of a single footprint.
All required arguments for this task have to be defined in KicadModParser
'''
def __init__(self):
self._arg = [] # arguments are set by KicadModParser
def write_footprint(self, filename):
raise NotImplementedError("write_footprint has to be implemented by child class")
def write_3d_model(self, filename):
raise NotImplementedError("write_3d_mode has to be implemented by child class")
class KicadModParser(object):
'''
Handles parsing of definition files, ..., and create KicadFootprint objects from it
'''
def __init__(self, footprint):
self._arg = []
self._footprint_arg = []
self.name = footprint.__name__
self.description = None
def add_argument(self, **kwarg)
pass
def set_arguments(self, arg)
pass
def get_arguments(self)
pass
def parse_file(self, filename)
pass
def run(self):
pass # parse cmd and controll all future operations (reading of files, writing of files, ...)
def generate_footprint_objects(self)
pass
To make an IPC compliant footprint generator, the component dimensions must be specified with tolerances, either as an interval of maximum and minimum, or as a nominal value with a +/- tolerance. Examples:
-
4.3
Exact nominal value -
4.3+-0.3
Nominal value and symmetrical tolerance (4.0 to 4.6) -
4.3+0.0-0.5
Nominal value with asymmetrical tolerances (3.8 to 4.3) -
4.0..4.6
Range tolerance (identical to example 2) -
<4.6
or..4.6
Only maximum value -
>4.3
or4.3..
Only minimum value
By default the quantities would be only in mm, but it could be possible to accept other units like mils later on (fairly low priority).