Hi, I'm a European under the age of 40, and as such my brain works in metric. So I'll write footprints for PCB in metric, then do the conversion over to those weird units as a last step. So I banged the attached script together. This replaces all instances of "Nmm" (e.g. '0.127mm') with their value in hundredths of thou. Maybe this'll also be useful to others who are on this list. For those who might be interested, this utility lives in the Student Robotics tools git repository: https://www.studentrobotics.org/cgit/tools.git/ Cheers, Rob
#!/bin/env python import re, sys, os from decimal import Decimal if len(sys.argv) < 2: print "Usage: %s PCB_FILE" % os.path.basename( sys.argv[0] ) print "Converts all units suffixed with mm to hundreths of thou." sys.exit(1) PCB_FILE = sys.argv[1] f = open( PCB_FILE, "r" ) def conv_ht(match): if match.groups()[0][0] == '"': return match.groups()[0] mm = Decimal( match.groups()[1] ) return str( int( mm / Decimal( "0.000254" ) ) ) fcontent = f.read() f.close() f = open( PCB_FILE, "w" ) f.write( re.sub( """(([0-9.]+)(mm)|".*?")""", conv_ht, fcontent ) )
Attachment:
signature.asc
Description: This is a digitally signed message part
_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user