I made a few changes to your script, and it now generates a symbol how I would expect it to be (which may not be the same as you
:
# File intented to demo some functions available in the Symbol Generator module.
# Another example is the connecor generator
# sys.path.append(os.path.join(sys.path[0],..))
# load KiCadSymbolGenerator path
# add KiCadSymbolGenerator to searchpath using export PYTHONPATH="${PYTHONPATH}<absolute path>/autogen/"
# or use relative module path. Example ..KiCadSymbolGenerator
import csv
from KiCadSymbolGenerator import *
generator = SymbolGenerator('VPC')
current_symbol = generator.addSymbol('PXI-2575', interchangable=Symbol.UnitsInterchangable.NOT_INTERCHANGEABLE)
current_symbol.setReference('U', at={'x':0, 'y':250})
current_symbol.setValue(at={'x':0, 'y':150})
i = 0
lastUnit = 1
with open('PXIe2575.csv', newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar="|")
for row in reader:
pinNum = int(row[1])
pinName = row[2]
pinUnit = int(row[3])
if lastUnit != pinUnit:
rect = DrawingRectangle(start={'x':-100, 'y':100}, end={'x':250, 'y':-i*100}, unit_idx=lastUnit)
current_symbol.drawing.append(rect)
i = 0
lastUnit = pinUnit
yPos = -100*i
i += 1
current_symbol.drawing.append(DrawingPin(at=Point({'x':-250, 'y':yPos}), number=pinNum,
orientation=DrawingPin.PinOrientation.RIGHT,
name=pinName, pin_length=150, unit_idx=pinUnit, deMorgan_idx=1))
rect = DrawingRectangle(start={'x':-100, 'y':100}, end={'x':250, 'y':-i*100}, unit_idx=lastUnit)
current_symbol.drawing.append(rect)
current_symbol.num_units = lastUnit
current_symbol.drawing.translate({'x':-50, 'y':0})
generator.writeFiles()
zilenc.zip (2.6 KB)