Когда я запускаю этот код, я получаю такой вывод:
# подключен к: COM9
импортировать maya.cmds как cmds
# Ошибка: Ошибка типа: строка файла 12: требуется целое число
Мой код:
import serial
ser = serial.Serial('COM9', 115200, timeout=1)
print("#connected to: " + ser.portstr)
print("import maya.cmds as cmds")
seq = []
count=1
while True:
for c in ser.readline():
seq.append(chr(c)) # convert from ANSII
joined_seq = ''.join(str(v) for v in seq)
if chr(c) =='\n':
#print("#Line" + str(count) + str(': ') + joined_seq )
seq = []
count += 1
if ';' in joined_seq:
joined_seqs = joined_seq.split(';')
joined_seq = joined_seqs[-2]
if 'Pitch =' in joined_seq:
joined_seq = joined_seq.replace('Pitch = ','')
print("cmds.setAttr('joint1.rx',", joined_seq,")")
if 'Roll =' in joined_seq:
joined_seq = joined_seq.replace('Roll = ','')
print("cmds.setAttr('joint1.ry',", joined_seq,")")
if 'Yaw =' in joined_seq:
joined_seq = joined_seq.replace('Yaw = ', '')
print("cmds.setAttr('joint1.rz',", joined_seq, ")")
ser.close()
строка 12 - это строка:
seq.append(chr(c)) # convert from ANSII