-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added poly conversion script, updated libraries
- Loading branch information
1 parent
0a8b839
commit 0af7052
Showing
105 changed files
with
42,993 additions
and
22,887 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-L | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-L_COPPER | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-M | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-M_COPPER | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-MINI | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-S | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty OSHW-LOGO-S_COPPER | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.2 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.3 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.4 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.05 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.5 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.6 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.7 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.8 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.9 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_COPPER_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_COPPER_.2 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_COPPER_.3 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_COPPER_EXPOSED_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_COPPER_EXPOSED_.2 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_COPPER_EXPOSED_.3 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_STOP_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.2 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.3 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.4 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.5 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.6 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.7 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.8 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_.9 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_FLAME_1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.2 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.3 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.4 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.5 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.6 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.7 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.8 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_.9 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_1 | ||
rem python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_NAME_WEB | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SPARKPUNK_LOGO_.1 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SPARKPUNK_LOGO_.2 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SPECTACLE_LOGO_NEGATIVE_1.5X0.5 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SPECTACLE_LOGO_NEGATIVE_2.2X1.0 | ||
python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SPECTACLE_LOGO_TITLE_0.35X0.70 | ||
rem The ludas logo was made incorrectly, do not render | ||
rem python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LUDUS-L | ||
rem python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LUDUS-M | ||
rem python ConvertModLineMultiPoly.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LUDUS-S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import os | ||
import sys | ||
import datetime | ||
|
||
MAX_EAGLE_PARTS = 1000 | ||
|
||
print"" # print a new line | ||
|
||
# C:\github\SparkFun-Eagle-Libraries C:\github\SparkFun-KiCad-Libraries\Conversion\TestLibs SparkFun-Capacitors | ||
numArgs = len(sys.argv) | ||
if numArgs < 4: | ||
#Print help | ||
print "Not enough arguments" | ||
print "Requires: <source path> <dest path> <mod name>" | ||
print "Example: Python file.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.2" | ||
exit() | ||
|
||
sourcePath = sys.argv[1] | ||
destPath = sys.argv[2] | ||
commonName = sys.argv[3] | ||
|
||
modLinePath = sourcePath + '\\' + commonName + '.kicad_mod' | ||
modPolyPath = destPath + '\\' + commonName + '.kicad_mod' | ||
logPath = destPath + '\\scriptOutputLog.txt' | ||
|
||
print 'Decoded paths:' | ||
print modLinePath | ||
print modPolyPath | ||
print logPath | ||
|
||
# Open a log file, or create a new one | ||
if os.path.isfile(logPath) == True: | ||
statinfo = os.stat(logPath) | ||
logFile = open(logPath, 'a') | ||
logFile.write('\n' + str(datetime.datetime.now())) | ||
logFile.write(" Appending log file\n") | ||
else: | ||
print "creating log file" | ||
logFile = open(logPath, "w+") | ||
logFile.write('\n' + str(datetime.datetime.now())) | ||
logFile.write(" Created log file\n") | ||
|
||
logFile.write( "modLinePath: " + modLinePath + '\n' ) | ||
logFile.write( "modPolyPath: " + modPolyPath + '\n' ) | ||
logFile.write( "logPath: " + logPath + '\n' ) | ||
|
||
# Open the export mod style file | ||
if os.path.isfile(modLinePath) == True: | ||
statinfo = os.stat(modLinePath) | ||
modLineFile = open(modLinePath, "r") | ||
# Read the KiCad Library to memeory | ||
kicadLineModMemory = modLineFile.read() | ||
# ..Now kicadLibMemory is a string that is the input file | ||
modLineFile.close() | ||
else: | ||
print "Invalid file name" | ||
|
||
|
||
#Create the output file memory | ||
kicadPolyModMemory = ''#start with blank file | ||
|
||
|
||
print "" | ||
|
||
|
||
logFile.write( "Starting to parse input mod file\n" ) | ||
|
||
|
||
#First, seek out initial "fp_line" text -- copy all lines before the line with it. | ||
locVar = kicadLineModMemory.find("fp_line", 0, len(kicadLineModMemory)) - 3 | ||
kicadPolyModMemory = kicadPolyModMemory + kicadLineModMemory[:locVar] | ||
|
||
#Second, capture the layer real quick for later | ||
layerDefStart = kicadLineModMemory.find("(layer", locVar, len(kicadLineModMemory)) | ||
layerDefEnd = kicadLineModMemory.find(")", layerDefStart, len(kicadLineModMemory)) + 1 | ||
|
||
#Now we want to do the following type format | ||
# (fp_poly (pts | ||
# (xy 0.982653 -2.516805) | ||
# (xy 1.161515 -2.508866) | ||
|
||
polyStart = '' | ||
workingOnPoly = 0 | ||
|
||
#But an input line looks like: | ||
# (fp_line (start 4.6482 -6.53796) (end 4.6482 -6.51764) (layer F.SilkS) (width 0.00762)) | ||
#... and all we need is the first point from it. | ||
#Find "(fp_line (start " statments until there are none | ||
exitCondition = 0 | ||
while exitCondition == 0: | ||
locVar = kicadLineModMemory.find("(fp_line (start ", locVar, len(kicadLineModMemory)) | ||
if locVar == -1: | ||
exitCondition = 1 | ||
else: | ||
# move to data | ||
print( str(locVar) ) | ||
point1DataStart = locVar + 16 | ||
point1DataEnd = kicadLineModMemory.find(")", point1DataStart, len(kicadLineModMemory)) | ||
locVar = kicadLineModMemory.find("(end ", locVar, len(kicadLineModMemory)) | ||
point2DataStart = locVar + 5 | ||
point2DataEnd = kicadLineModMemory.find(")", point2DataStart, len(kicadLineModMemory)) | ||
#Create the point in file | ||
if workingOnPoly == 0: #also memorize this beginning point | ||
kicadPolyModMemory = kicadPolyModMemory + "(fp_poly (pts\n" | ||
kicadPolyModMemory = kicadPolyModMemory + " (xy " + kicadLineModMemory[point1DataStart:point1DataEnd] + ")\n" | ||
workingOnPoly = 1 | ||
polyStart = kicadLineModMemory[point1DataStart:point1DataEnd] | ||
else: | ||
#already working on poly, see if this is the end | ||
kicadPolyModMemory = kicadPolyModMemory + " (xy " + kicadLineModMemory[point1DataStart:point1DataEnd] + ")\n" | ||
#print polyStart | ||
#print kicadLineModMemory[point2DataStart:point2DataEnd] | ||
if polyStart == kicadLineModMemory[point2DataStart:point2DataEnd]: | ||
#Got a loop | ||
workingOnPoly = 0 | ||
#Print close parenthesis | ||
kicadPolyModMemory = kicadPolyModMemory + ") " + kicadLineModMemory[layerDefStart:layerDefEnd] + " (width 0.01))\n" | ||
|
||
|
||
# Now finish the file | ||
# (xy 15.279895 -0.93621)) (layer F.SilkS) (width 0.01)) | ||
#) | ||
if workingOnPoly == 1: | ||
#didn't finish proper | ||
kicadPolyModMemory = kicadPolyModMemory + ") " + kicadLineModMemory[layerDefStart:layerDefEnd] + " (width 0.01))\n" | ||
kicadPolyModMemory = kicadPolyModMemory + ")\n" | ||
|
||
#print "" | ||
#print "Number of parts inspected: ", partsInspected | ||
#print "Number of valid parts found: ", validParts | ||
#print "Number of parts skipped: ", skippedParts | ||
#print "Number not found in KiCad libs: ", notFoundInKicadLib | ||
#print "Number of DCM entries created: ", dcmRecordsCreated | ||
#print "Number PROD_ID fields created: ", prodIDFieldsAdded | ||
#print "Default PROD_ID used: ", defaultProdIDsCreated | ||
#print "" | ||
# | ||
#logFile.write( "Number of parts inspected: " + str(partsInspected) + '\n' ) | ||
#logFile.write( "Number of valid parts found: " + str(validParts) + '\n' ) | ||
#logFile.write( "Number of parts skipped: " + str(skippedParts) + '\n' ) | ||
#logFile.write( "Number not found in KiCad libs: " + str(notFoundInKicadLib) + '\n' ) | ||
#logFile.write( "Number of DCM entries created: " + str(dcmRecordsCreated) + '\n' ) | ||
#logFile.write( "Number PROD_ID fields created: " + str(prodIDFieldsAdded) + '\n' ) | ||
#logFile.write( "Default PROD_ID used: " + str(defaultProdIDsCreated) + '\n' ) | ||
|
||
#eagleLbrFile.close() | ||
|
||
#logFile.write(kicadLibMemory) # Enable this line to write memory to logfile | ||
logFile.write(str(datetime.datetime.now()) + ' ' ) | ||
logFile.write("Closing log file\n\n\n\n") | ||
logFile.close() | ||
|
||
# Write out the kicadPolyModMemory | ||
if os.path.isfile(modPolyPath) == True: | ||
statinfo = os.stat(modPolyPath) | ||
modPolyFile = open(modPolyPath, "w+") | ||
# Read the KiCad Library to memeory | ||
else: | ||
print "creating poly .kicad_mod file" | ||
modPolyFile = open(modPolyPath, "w+") | ||
modPolyFile.write(kicadPolyModMemory) # Enable this line to write memory to OUTPUT | ||
modPolyFile.close() | ||
|
||
|
||
print "File IO complete" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import os | ||
import sys | ||
import datetime | ||
|
||
MAX_EAGLE_PARTS = 1000 | ||
|
||
print"" # print a new line | ||
|
||
# C:\github\SparkFun-Eagle-Libraries C:\github\SparkFun-KiCad-Libraries\Conversion\TestLibs SparkFun-Capacitors | ||
numArgs = len(sys.argv) | ||
if numArgs < 4: | ||
#Print help | ||
print "Not enough arguments" | ||
print "Requires: <source path> <dest path> <mod name>" | ||
print "Example: Python file.py C:\github\SparkFun-KiCad-Libraries\SparkFun.pretty C:\github\SparkFun-KiCad-Libraries\Export.pretty SFE_LOGO_FLAME_.2" | ||
exit() | ||
|
||
sourcePath = sys.argv[1] | ||
destPath = sys.argv[2] | ||
commonName = sys.argv[3] | ||
|
||
modLinePath = sourcePath + '\\' + commonName + '.kicad_mod' | ||
modPolyPath = destPath + '\\' + commonName + '.kicad_mod' | ||
logPath = destPath + '\\scriptOutputLog.txt' | ||
|
||
print 'Decoded paths:' | ||
print modLinePath | ||
print modPolyPath | ||
print logPath | ||
|
||
# Open a log file, or create a new one | ||
if os.path.isfile(logPath) == True: | ||
statinfo = os.stat(logPath) | ||
logFile = open(logPath, 'a') | ||
logFile.write('\n' + str(datetime.datetime.now())) | ||
logFile.write(" Appending log file\n") | ||
else: | ||
print "creating log file" | ||
logFile = open(logPath, "w+") | ||
logFile.write('\n' + str(datetime.datetime.now())) | ||
logFile.write(" Created log file\n") | ||
|
||
logFile.write( "modLinePath: " + modLinePath + '\n' ) | ||
logFile.write( "modPolyPath: " + modPolyPath + '\n' ) | ||
logFile.write( "logPath: " + logPath + '\n' ) | ||
|
||
# Open the export mod style file | ||
if os.path.isfile(modLinePath) == True: | ||
statinfo = os.stat(modLinePath) | ||
modLineFile = open(modLinePath, "r") | ||
# Read the KiCad Library to memeory | ||
kicadLineModMemory = modLineFile.read() | ||
# ..Now kicadLibMemory is a string that is the input file | ||
modLineFile.close() | ||
else: | ||
print "Invalid file name" | ||
|
||
|
||
#Create the output file memory | ||
kicadPolyModMemory = ''#start with blank file | ||
|
||
|
||
print "" | ||
|
||
|
||
logFile.write( "Starting to parse input mod file\n" ) | ||
|
||
#First, seek out initial "fp_line" text -- copy all lines before the line with it. | ||
locVar = kicadLineModMemory.find("fp_line", 0, len(kicadLineModMemory)) - 3 | ||
kicadPolyModMemory = kicadPolyModMemory + kicadLineModMemory[:locVar] | ||
|
||
#Second, capture the layer real quick for later | ||
layerDefStart = kicadLineModMemory.find("(layer", locVar, len(kicadLineModMemory)) | ||
layerDefEnd = kicadLineModMemory.find(")", layerDefStart, len(kicadLineModMemory)) + 1 | ||
|
||
#Now we want to do the following type format | ||
# (fp_poly (pts | ||
# (xy 0.982653 -2.516805) | ||
# (xy 1.161515 -2.508866) | ||
kicadPolyModMemory = kicadPolyModMemory + "(fp_poly (pts\n" | ||
|
||
#But an input line looks like: | ||
# (fp_line (start 4.6482 -6.53796) (end 4.6482 -6.51764) (layer F.SilkS) (width 0.00762)) | ||
#... and all we need is the first point from it. | ||
#Find "(fp_line (start " statments until there are none | ||
exitCondition = 0 | ||
while exitCondition == 0: | ||
locVar = kicadLineModMemory.find("(fp_line (start ", locVar, len(kicadLineModMemory)) | ||
if locVar == -1: | ||
exitCondition = 1 | ||
else: | ||
# move to data | ||
print( str(locVar) ) | ||
locVar = locVar + 16 | ||
dataStart = locVar | ||
dataEnd = kicadLineModMemory.find(")", dataStart, len(kicadLineModMemory)) | ||
#Create the point in file | ||
kicadPolyModMemory = kicadPolyModMemory + " (xy " + kicadLineModMemory[dataStart:dataEnd] + ")\n" | ||
|
||
# Now finish the file | ||
# (xy 15.279895 -0.93621)) (layer F.SilkS) (width 0.01)) | ||
#) | ||
|
||
kicadPolyModMemory = kicadPolyModMemory + ") " + kicadLineModMemory[layerDefStart:layerDefEnd] + " (width 0.01))\n" | ||
kicadPolyModMemory = kicadPolyModMemory + ")\n" | ||
|
||
#print "" | ||
#print "Number of parts inspected: ", partsInspected | ||
#print "Number of valid parts found: ", validParts | ||
#print "Number of parts skipped: ", skippedParts | ||
#print "Number not found in KiCad libs: ", notFoundInKicadLib | ||
#print "Number of DCM entries created: ", dcmRecordsCreated | ||
#print "Number PROD_ID fields created: ", prodIDFieldsAdded | ||
#print "Default PROD_ID used: ", defaultProdIDsCreated | ||
#print "" | ||
# | ||
#logFile.write( "Number of parts inspected: " + str(partsInspected) + '\n' ) | ||
#logFile.write( "Number of valid parts found: " + str(validParts) + '\n' ) | ||
#logFile.write( "Number of parts skipped: " + str(skippedParts) + '\n' ) | ||
#logFile.write( "Number not found in KiCad libs: " + str(notFoundInKicadLib) + '\n' ) | ||
#logFile.write( "Number of DCM entries created: " + str(dcmRecordsCreated) + '\n' ) | ||
#logFile.write( "Number PROD_ID fields created: " + str(prodIDFieldsAdded) + '\n' ) | ||
#logFile.write( "Default PROD_ID used: " + str(defaultProdIDsCreated) + '\n' ) | ||
|
||
#eagleLbrFile.close() | ||
|
||
#logFile.write(kicadLibMemory) # Enable this line to write memory to logfile | ||
logFile.write(str(datetime.datetime.now()) + ' ' ) | ||
logFile.write("Closing log file\n\n\n\n") | ||
logFile.close() | ||
|
||
# Write out the kicadPolyModMemory | ||
if os.path.isfile(modPolyPath) == True: | ||
statinfo = os.stat(modPolyPath) | ||
modPolyFile = open(modPolyPath, "w+") | ||
# Read the KiCad Library to memeory | ||
else: | ||
print "creating poly .kicad_mod file" | ||
modPolyFile = open(modPolyPath, "w+") | ||
modPolyFile.write(kicadPolyModMemory) # Enable this line to write memory to OUTPUT | ||
modPolyFile.close() | ||
|
||
|
||
print "File IO complete" |
Oops, something went wrong.