Hi all,
I have added some changes to tragesym:
        - Build the symbol at the origin (0,0), so it doesn't need translated.
        - The user can put some space between two pins in the same side just
adding a pin called "SPACER" when he wants to. This doesn't generate a
pin, but skip that pin location.

Comments?

Carlos


--- /home/cnieves/temp/geda_cvs/geda_cvs/geda/devel/utils/scripts/tragesym	2004-11-14 19:08:23.000000000 +0100
+++ tragesym	2005-04-10 11:40:01.307611608 +0200
@@ -29,7 +29,7 @@
 import sys, string
 
 ##################### GLOBALS ############################################
-VERSION="0.0.7"
+VERSION="0.0.8"
 
 CHARHIGH=26
 pre_options={"wordswap":"yes"
@@ -157,6 +157,8 @@
 
 def checkpins(pinlist):
     for pin in pinlist:
+    	if (pin[P_LABEL]=="SPACER"):
+    	    continue
         try:
             if pin[P_STYLE] != "none":
                 string.atoi(pin[P_SEQ])
@@ -250,97 +252,22 @@
     o_sort=options["sort_labels"]
 
     pinlength = 300
-    topleftx, toplefty = 50000, 30000  ## top left of the box
-    textx, texty= topleftx , toplefty + 50
-    urefx, urefy= topleftx + o_symwidth, toplefty + 100
-    prightx, prighty= topleftx + pinlength + o_symwidth, toplefty - o_vdist
-    pleftx, plefty= topleftx - pinlength, toplefty - o_vdist
-    ptopx, ptopy= topleftx + o_symwidth + 1000, toplefty + pinlength
-    pbottomx, pbottomy= topleftx + o_symwidth + 1000, toplefty - 2000 
+    bottomleftx, bottomlefty = pinlength, 200  ## bottom left of the box
+    textx, texty= bottomleftx , bottomlefty + 50
+    prightx, prighty= bottomleftx + pinlength + o_symwidth, bottomlefty + o_vdist
+    pleftx, plefty= bottomleftx - pinlength, bottomlefty + o_vdist
+    ptopx, ptopy= bottomleftx + o_symwidth + 1000, bottomlefty + pinlength
+    pbottomx, pbottomy= bottomleftx + o_symwidth + 1000, bottomlefty - 2000 
     
     f = open(filename, "w")
-    texty_basis=texty
 
+### Draw the symbol version
     if attr.has_key(("version",1)):
         value=attr[("version",1)]
-        f.write("v " + value + "\n")
+        f.write("v " + value + " 1\n")
     else:
         print "version attribut missing"
-    if attr.has_key(("refdes",1)):
-        value=attr[("refdes",1)]
-        f.write("T %i"% urefx +" %i"% urefy +" 8 10 1 1 0 6 1\n")
-        f.write("refdes=" + value + "\n")
-    else:
-        print "refdes attribut missing"
-    if attr.has_key(("name",1)):
-        value=attr[("name",1)]
-        f.write("T %i" %textx + " %i"% texty + " 9 10 1 0 0 0 1\n")
-        f.write(value + "\n")
-        texty=texty+200
-    else:
-        print "name attribut missing"
-    if attr.has_key(("device",1)):
-        value=attr[("device",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("device=" + value + "\n")
-        texty=texty+200
-    else:
-        print "device attribut missing"
-    if attr.has_key(("footprint",1)):
-        value=attr[("footprint",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("footprint=" + value + "\n")
-        texty=texty+200
-    else:
-        print "footprint attribut missing"
-    if attr.has_key(("author",1)):
-        value=attr[("author",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("author=" + value + "\n")
-        texty=texty+200
-    else:
-        print "author attribut missing"
-    if attr.has_key(("documentation",1)):
-        value=attr[("documentation",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("documentation=" + value + "\n")
-        texty=texty+200
-    else:
-        print "documentation attribut missing"
-    if attr.has_key(("description",1)):
-        value=attr[("description",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("description=" + value + "\n")
-        texty=texty+200
-    else:
-        print "description attribut missing"
-    if attr.has_key(("numslots",1)):
-        value=attr[("numslots",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("numslots=" + value + "\n")
-        texty=texty+200
-    else:
-        print "numslots attribut missing"
-    if attr.has_key(("slot",1)):
-        value=attr[("slot",1)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("slot=" + value + "\n")
-        texty=texty+200
-    i = 1
-    while attr.has_key(("slotdef",i)):
-        value=attr[("slotdef",i)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("slotdef=" + value + "\n")
-        texty=texty+200
-        i = i + 1
-    i = 1
-    while attr.has_key(("comment",i)):
-        value=attr[("comment",i)]
-        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
-        f.write("comment=" + value + "\n")
-        texty=texty+200
-        i = i + 1
-    
+   
     nets={}
     for pin in pins:
         if pin[P_STYLE] == "none":
@@ -356,6 +283,30 @@
     if o_sort == "yes":
         pins.sort(pinsort)
 
+### Count the number of pins in each side
+
+    numpleft=0
+    numpright=0
+    numpbottom=0
+    numptop = 0
+    for pin in pins:
+    	if pin[P_POS] == "l": # left pin
+    		numpleft=numpleft+1
+    	elif pin[P_POS] == "r": #right pin
+    		numpright=numpright+1
+    	elif pin[P_POS] == "b": #right pin
+    		numpbottom=numpbottom+1
+    	elif pin[P_POS] == "t": #right pin
+    		numptop=numptop+1
+
+### Calculate the position of the pins in the left and right side.    
+    if numpleft >  numpright:
+        plefty=plefty+(numpleft-1)*o_vdist
+        prighty = plefty
+    else :
+        prighty=prighty+(numpright-1)*o_vdist
+        plefty = prighty
+
     for pin in pins:
         if pin[P_STYLE] == "none": #
             continue
@@ -416,6 +367,8 @@
                 negl=(0,20,1,0)
                 swap=0
             ptopx=ptopx + o_hdist
+        if (pin[P_LABEL]=="SPACER"):
+            continue
 ### draw the pin
         if (pin[P_STYLE]=="dot" or  #short pin and dot?
             pin[P_STYLE]=="dotclk"):
@@ -492,13 +445,99 @@
             f.write("L %i"%x1+" %i"%y1+" %i"%x3+" %i"%y3 + " 3 0 0 0 -1 -1\n")
 ### draw a box 
     width=o_symwidth
-    if plefty < prighty:
-        high=toplefty - plefty 
+    if numpleft < numpright:
+        high=(numpright+1)*o_vdist 
     else:
-        high=toplefty - prighty
-    bottomy = toplefty - high
-    f.write("B %i"%topleftx+" %i"%bottomy+" %i"%width+" %i"%high+
+        high=(numpleft+1)*o_vdist 
+    topy = bottomlefty + high
+    f.write("B %i"%bottomleftx+" %i"%bottomlefty+" %i"%width+" %i"%high+
             " 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n")
+
+### draw the attributes
+    urefx, urefy= bottomleftx, bottomlefty + high + 100
+    textx = urefx
+    texty = bottomlefty - 200
+    
+    if attr.has_key(("refdes",1)):
+        value=attr[("refdes",1)]
+        f.write("T %i"% urefx +" %i"% urefy +" 8 10 1 1 0 0 1\n")
+        f.write("refdes=" + value + "\n")
+    else:
+        print "refdes attribut missing"
+    if attr.has_key(("name",1)):
+        value=attr[("name",1)]
+        f.write("T %i" %textx + " %i"% texty + " 9 10 1 0 0 0 1\n")
+        f.write(value + "\n")
+        texty=texty+200
+    else:
+        print "name attribut missing"
+    if attr.has_key(("device",1)):
+        value=attr[("device",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("device=" + value + "\n")
+        texty=texty+200
+    else:
+        print "device attribut missing"
+
+    textx = urefx
+    texty = urefy + 200
+
+    if attr.has_key(("footprint",1)):
+        value=attr[("footprint",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("footprint=" + value + "\n")
+        texty=texty+200
+    else:
+        print "footprint attribut missing"
+    if attr.has_key(("author",1)):
+        value=attr[("author",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("author=" + value + "\n")
+        texty=texty+200
+    else:
+        print "author attribut missing"
+    if attr.has_key(("documentation",1)):
+        value=attr[("documentation",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("documentation=" + value + "\n")
+        texty=texty+200
+    else:
+        print "documentation attribut missing"
+    if attr.has_key(("description",1)):
+        value=attr[("description",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("description=" + value + "\n")
+        texty=texty+200
+    else:
+        print "description attribut missing"
+    if attr.has_key(("numslots",1)):
+        value=attr[("numslots",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("numslots=" + value + "\n")
+        texty=texty+200
+    else:
+        print "numslots attribut missing"
+    if attr.has_key(("slot",1)):
+        value=attr[("slot",1)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("slot=" + value + "\n")
+        texty=texty+200
+    i = 1
+    while attr.has_key(("slotdef",i)):
+        value=attr[("slotdef",i)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("slotdef=" + value + "\n")
+        texty=texty+200
+        i = i + 1
+    i = 1
+    while attr.has_key(("comment",i)):
+        value=attr[("comment",i)]
+        f.write("T %i" %textx + " %i"% texty + " 5 10 0 0 0 0 1\n")
+        f.write("comment=" + value + "\n")
+        texty=texty+200
+        i = i + 1
+ 
+
     return 0
 
 def mergeoptions(source_opt,pre_opt):

Reply via email to