Advertisement
Guest User

Untitled

a guest
Jan 4th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. # File intented to demo some functions available in the Symbol Generator module.
  2. # Another example is the connecor generator
  3.  
  4. # sys.path.append(os.path.join(sys.path[0],..))
  5. # load KiCadSymbolGenerator path
  6. # add KiCadSymbolGenerator to searchpath using export PYTHONPATH="${PYTHONPATH}<absolute path>/autogen/"
  7. # or use relative module path. Example ..KiCadSymbolGenerator
  8.  
  9. import csv
  10. from KiCadSymbolGenerator import *
  11.  
  12. generator = SymbolGenerator('VPC')
  13.  
  14. current_symbol = generator.addSymbol('PXI-2575')
  15. current_symbol.setReference('U', at={'x':0, 'y':150})
  16. current_symbol.setValue(at={'x':0, 'y':-150})
  17.  
  18. i = 1.0
  19. lastUnit = 1
  20.  
  21. with open('PXIe2575.csv', newline='') as csvfile:
  22.     reader = csv.reader(csvfile, delimiter=',', quotechar="|")
  23.     for row in reader:
  24.         pinNum = int(row[1])
  25.         pinName = row[2]
  26.         pinUnit = int(row[3])
  27.         if lastUnit != pinUnit:
  28.             i = 1
  29.         else:
  30.             lastUnit = pinUnit
  31.         i += 1
  32.         yPos = -254*i
  33.         current_symbol.drawing.append(DrawingPin(at=Point({'x':-254, 'y':yPos}, grid=100), number=pinNum,
  34.                                                           orientation=DrawingPin.PinOrientation.RIGHT,
  35.                                                          name=pinName, length=5.08, unit_idx=pinUnit, deMorgan_idx=pinUnit))
  36.  
  37.  
  38.  
  39.  
  40. rect = DrawingRectangle(start={'x':-100, 'y':100}, end={'x':100, 'y':-100})
  41. current_symbol.drawing.append(rect)
  42.  
  43. #current_symbol.drawing.translate({'x':50, 'y':100})
  44.  
  45. #testpoint = Point({})
  46. #testpoint2 = testpoint.translate(distance={'x':1,'y':1}, apply_on_copy=True) #apply on copy can be used to generate multiple equal parts.
  47.  
  48. generator.writeFiles()
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement