diff --git a/compile.bat b/compile.bat new file mode 100644 index 0000000..46c8cd4 --- /dev/null +++ b/compile.bat @@ -0,0 +1,2 @@ +py -3.4 -m py2exe.build_exe lt2ti.py +pause \ No newline at end of file diff --git a/dist/lt2ti.ini b/dist/lt2ti.ini new file mode 100644 index 0000000..a9ef32c --- /dev/null +++ b/dist/lt2ti.ini @@ -0,0 +1,3 @@ +[general] +symdir=\..\sym32a +includepreamble=true \ No newline at end of file diff --git a/dist/lt2ti_Test.bat b/dist/lt2ti_Test.bat new file mode 100644 index 0000000..66498d9 --- /dev/null +++ b/dist/lt2ti_Test.bat @@ -0,0 +1,2 @@ +lt2ti.exe examples\Test.asc > Test.log +pause \ No newline at end of file diff --git a/lt2ti.py b/lt2ti.py index abaf33e..b8cd241 100644 --- a/lt2ti.py +++ b/lt2ti.py @@ -99,12 +99,22 @@ def __init__(self): self.lt2tscale = (1.0/48.0); self.includepreamble = True; - self.scriptdir = (os.path.dirname(os.path.realpath(__file__))); + try: + approot2 = (os.path.dirname(os.path.realpath(__file__))); + approot = os.path.dirname(os.path.abspath(__file__)) + except NameError: # We are the main py2exe script, not a module + import sys + approot = os.path.dirname(os.path.abspath(sys.argv[0])) + + self.scriptdir = (approot); self.symfilebasepath = 'sym'+os.sep; + configfileloc = self.scriptdir+os.sep+'lt2ti.ini' + print('lt2ti: Loading config at "'+configfileloc+'"') + self.config = configparser.RawConfigParser() - self.config.read(self.scriptdir+os.sep+'lt2ti.ini') + self.config.read(configfileloc) if (self.config.has_option('general', 'symdir')): self.symfilebasepath = self.config.get('general', 'symdir') + os.sep; @@ -119,6 +129,8 @@ def __init__(self): if (self.config.has_option('general', 'includepreamble')): includepreamble = self.config.get('general', 'includepreamble'); self.includepreamble = ((str(includepreamble).lower() == 'true') or ((includepreamble) == '1')) + + print('lt2ti ready for conversion.') @@ -144,6 +156,7 @@ def symresetPin(self): return; def readASYFile(self, relfileandpath): + print('Loading Symbol file "'+relfileandpath+'"...') # read symbol file self.symlinecnt = 0; aSymbol = None; @@ -416,8 +429,8 @@ def _resetLast(self): self.circDict.addText(self.lastText); self.lastText = None; - def readASCFile(self, fielandpath): - + def readASCFile(self, fileandpath): + print('Reading ASC file "'+fileandpath+'"...') self.lastComponent = None; self.lastSymbol = None; self.lastAttributesDict = {}; @@ -430,9 +443,9 @@ def readASCFile(self, fielandpath): self.linecnt = 0; try : - fhs = open(fielandpath, mode='r', newline=None); + fhs = open(fileandpath, mode='r', newline=None); except Exception as e: - print('could not open ASC file "'+fielandpath+'" (cwd="'+os.curdir+'")'); + print('could not open ASC file "'+fileandpath+'" (cwd="'+os.curdir+'")'); return None; @@ -779,6 +792,7 @@ def copyFileContentsToHandle(self,source,hdestination): fhs.close(); def writeCircuiTikz(self, outfile): + print('Writing Tex commands to "'+outfile+'"...') xscale = 1 * self.lt2tscale; yscale = -1 * self.lt2tscale; # y is inverse for LTspice files xoffset = 0; @@ -1118,7 +1132,7 @@ def wiresToPolyWires(self): for coord, dictWires in coordWireDictCpy.items(): isAtCompPin = (coord in self.coordCompPinDict); if (isAtCompPin): - print("Wire position "+str(coord)+' is incident with a component pin. Conversion to polywire suppressed.'); + print(" Wire position "+str(coord)+' is incident with a component pin. Conversion to polywire suppressed.'); if (len(dictWires) == 2) and (coord not in self.coordCompDict) and (not isAtCompPin): # two wires joined at this point and no component node there. convert to PolyWire changes = True # we join two wires, thus change the set and must reprocess it @@ -1147,6 +1161,7 @@ def wiresToPolyWires(self): # if len(dictWires) == 2: # two wires joined at this point: convert them into a PolyWire # no more changes + print("Joining operations completed.") return cnt; class Attribute: @@ -1933,20 +1948,23 @@ def JoinWires(cls, Wire1, Wire2): if (Wire1.getP1Tuple() == Wire2.getP1Tuple()): # joined at P1 back to back Wire1 <-> Wire2 + print(" Wire1 <-> Wire2") x1_ = Wire1.x2 y1_ = Wire1.y2 if (type(Wire1) is PolyWire): an = list(Wire1.xn); # copy so we can reverse it if necessary an.reverse(); # turn the wire coordinate list 'around' - xn.extend(an); + xn_.extend(an); an = list(Wire1.yn); # copy so we can reverse it if necessary an.reverse(); # turn the wire coordinate list 'around' - yn.extend(an); + yn_.extend(an); xn_.append(Wire1.x1) yn_.append(Wire1.y1) + print(" (Wire1 complete..)") + if (type(Wire2) is PolyWire): an = list(Wire2.xn); # copy so we can reverse it if necessary #an.reverse(); # turn the wire coordinate list 'around' @@ -1959,6 +1977,7 @@ def JoinWires(cls, Wire1, Wire2): y2_ = Wire2.y2 elif (Wire1.getP2Tuple() == Wire2.getP2Tuple()): # joined at P2 face to face Wire1 >-< Wire2 + print(" Wire1 >-< Wire2") x1_ = Wire1.x1 y1_ = Wire1.y1 @@ -1985,6 +2004,7 @@ def JoinWires(cls, Wire1, Wire2): y2_ = Wire2.y1 elif (Wire1.getP2Tuple() == Wire2.getP1Tuple()): # flow from Wire1 -> Wire2 + print(" Wire1 -> Wire2") x1_ = Wire1.x1 y1_ = Wire1.y1 @@ -2011,6 +2031,7 @@ def JoinWires(cls, Wire1, Wire2): y2_ = Wire2.y2 elif (Wire1.getP1Tuple() == Wire2.getP2Tuple()): # flow from Wire2 -> Wire1 + print(" Wire2 -> Wire1") x1_ = Wire2.x1 y1_ = Wire2.y1 @@ -2039,6 +2060,8 @@ def JoinWires(cls, Wire1, Wire2): # unknown print("Error: Unknown wire configuration for PolyWire:JoinWires") + print(" Constructing new wire object..") + pw = cls(name_, x1_, y1_, xn_, yn_, x2_, y2_) return pw; @@ -2397,5 +2420,13 @@ def main(): l2tobj.readASCFile(args.file); l2tobj.writeCircuiTikz(args.file+'.tex'); -if __name__ == '__main__': - main(); \ No newline at end of file + +try: + approot = os.path.dirname(os.path.abspath(__file__)) + if __name__ == '__main__': + main(); +except NameError: # We are the main py2exe script, not a module + import sys + approot = os.path.dirname(os.path.abspath(sys.argv[0])) + main(); + diff --git a/lt2ti_Prj.wpr b/lt2ti_Prj.wpr new file mode 100644 index 0000000..166da5c --- /dev/null +++ b/lt2ti_Prj.wpr @@ -0,0 +1,9 @@ +#!wing +#!version=6.0 +################################################################## +# Wing IDE project file # +################################################################## +[project attributes] +proj.file-list = [loc('lt2ti.py'), + loc('test_lt2ti.py')] +proj.file-type = 'shared' diff --git a/sym32a/latex_preamble.tex b/sym32a/latex_preamble.tex index ad80430..bb1fa2a 100644 --- a/sym32a/latex_preamble.tex +++ b/sym32a/latex_preamble.tex @@ -1,7 +1,7 @@ % automatically generated document using lt2circuiTikz \documentclass[tikz,margin={2pt 2pt 2pt 2pt}]{standalone} \usepackage[compatibility,siunitx, americanvoltages, americancurrents, europeanresistors, europeaninductors, americanports,% - straightlabels, fetbodydiode]{circuitikz} + straightlabels, fetbodydiode, straightvoltages]{circuitikz} \usepackage{tikz,amsmath, amssymb,bm,color,pgfkeys,siunitx,ifthen,ulem} \usepackage{pgfplots} \pgfplotsset{compat=1.14} diff --git a/sym32a/voltage.asy2tex b/sym32a/voltage.asy2tex index 572e064..ab482d3 100644 --- a/sym32a/voltage.asy2tex +++ b/sym32a/voltage.asy2tex @@ -5,6 +5,5 @@ BeginPinList EndPinList TexElementName *V BeginTex - %\draw (#+:x1#, #+:y1#) to[#self.symbol.latexElementName#, l=#self.name#, a=#self.value#, ##mirror##, rotate=##rotate##,##options##] (#-:x1#,#-:y1#){}; - \draw (#+:x1#, #+:y1#) to[#self.symbol.latexElementName#, l=#self.name#, a=#self.value#,##mirror##, #+:junction#-#-:junction#, ##options##] (#-:x1#,#-:y1#){}; + \draw (#+:x1#, #+:y1#) to[#self.symbol.latexElementName#, l_=#self.name#, a^=#self.value#,##mirror##, #+:junction#-#-:junction#, ##options##] (#-:x1#,#-:y1#){}; EndTex diff --git a/sym32b/latex_preamble.tex b/sym32b/latex_preamble.tex index 299d73d..d4c3818 100644 --- a/sym32b/latex_preamble.tex +++ b/sym32b/latex_preamble.tex @@ -1,7 +1,7 @@ % automatically generated document using lt2circuiTikz \documentclass[tikz,margin={2pt 2pt 2pt 2pt}]{standalone} \usepackage[compatibility,siunitx, americanvoltages, americancurrents, europeanresistors, europeaninductors, americanports,% - straightlabels, fetbodydiode]{circuitikz} + straightlabels, fetbodydiode, straightvoltages]{circuitikz} \usepackage{tikz,amsmath, amssymb,bm,color,pgfkeys,siunitx,ifthen,ulem} \usepackage{pgfplots} \pgfplotsset{compat=1.14} diff --git a/sym48/latex_preamble.tex b/sym48/latex_preamble.tex index a63df79..c8eea8c 100644 --- a/sym48/latex_preamble.tex +++ b/sym48/latex_preamble.tex @@ -1,7 +1,7 @@ % automatically generated document using lt2circuiTikz \documentclass[tikz,margin={2pt 2pt 2pt 2pt}]{standalone} \usepackage[compatibility,siunitx, americanvoltages, americancurrents, europeanresistors, europeaninductors, americanports,% - straightlabels, fetbodydiode]{circuitikz} + straightlabels, fetbodydiode, straightvoltages]{circuitikz} \usepackage{tikz,amsmath, amssymb,bm,color,pgfkeys,siunitx,ifthen,ulem} \usepackage{pgfplots} \pgfplotsset{compat=1.14}