Интегриране на РепРап в Blender

From RepRap
Revision as of 13:02, 31 January 2012 by Radoslav (talk | contribs)
Jump to: navigation, search

Това е първият ми опит за интегриране на РепРап в 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()