Интегриране на РепРап в Blender
Това е първият ми опит за интегриране на РепРап в Blender.
За целта ще използваме последната версия на Blender [1], PySerial [2] и Printrun [3].
Необходим софтуер:
1. Blender 3.61
2. pyserial (инсталация за python3)
3. Printrun (модифицирана версия на printcore.py за работа с python 3.2)
Код на printcore_3p2.py. Това е модифицирана версия на printcore.py от Printrun в хранилището на Климент.
Хардуер:
1. RepRap Prusa с инсталиран Sprinter [4] firmware.
Последователност в Blender:
# ######################################################### # # RepRap communication using Sprinter firmware and Printrun # # License: GPL (choose one) # Author: Radoslav Borisov # Date: 20.12.2011 # # ######################################################### import sys import bpy import time # Define path for pyserial here: PySerialPath = '/usr/local/lib/python3.2/dist-packages' # Define path for Printrun here: PrintrunPath = '/home/borisov-r/Downloads/reprap/Printrun' allPath = sys.path # testPathLength = len(testPath) addPySerial = True addPrintrun = True for path in allPath: # checks if the paths already exists if PySerialPath in path: addPySerial = False if PrintrunPath in path: addPrintrun = False # add pyserial path if addPySerial: sys.path.append(PySerialPath) print('PySerial added to path.') # add Printrun path if addPrintrun: sys.path.append(PrintrunPath) print('Printrun added to path.') import serial # adds serial interface import printcore_3p2 # adds communication with reprap firmware # reprap intialization give correct USB port and Baud Rate # p=printcore_3p2.printcore('/dev/ttyACM0',115200) - example p=printcore_3p2.printcore('Path to USB',BR) # Communication examples p.printer.write(bytes("G91\n","ascii")) # set relative coordinate system p.printer.write(bytes("G1 Y5\n","ascii")) # move Y, 5 mm in plus direction p.disconnect()
Примерна връзка на репрап в Блендер:
import sys import bpy import time # Define path for pyserial here: PySerialPath = '/usr/local/lib/python3.2/dist-packages' allPath = sys.path # testPathLength = len(testPath) addPySerial = True for path in allPath: # checks if the paths already exists if PySerialPath in path: addPySerial = False # add pyserial path if addPySerial: sys.path.append(PySerialPath) print('PySerial added to path.') >>> from serial import Serial >>> port = '/dev/ttyACM0' >>> port '/dev/ttyACM0' >>> baud = 115200 >>> pesho = Serial(port, baud, timeout = 5) >>> pesho.write("G91") Traceback (most recent call last): File "<blender_console>", line 1, in <module> File "/usr/local/lib/python3.2/dist-packages/serial/serialposix.py", line 475, in write n = os.write(self.fd, d) TypeError: 'str' does not support the buffer interface >>> pesho.write(bytes("G91\n","ascii")) 4 >>> pesho.write(bytes("G1 X5\n","ascii")) 6 >>> pesho.write(bytes("G1 X5\n","ascii")) 6 >>> pesho.write(bytes("G1 X5\n","ascii")) 6 >>> pesho.write(bytes("G1 X-5\n","ascii")) 7 >>> >>> pesho.write(bytes("G1 X-5\n","ascii")) 7 >>> pesho.close()