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

From RepRap
Revision as of 11:50, 21 December 2011 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 time        # addds delay() function
import sys
import bpy
 
# 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

# a verification if the printer is online should be added like:
# while (not p.online or wait > 100):
#     time.sleep(1)
#     wait += 1
#     print( str(wait) + "\n")
# if p.online:
  
p.printer.write(bytes('G1 X5\n','ascii'))     # x movement
p.printer.write(bytes('G1 Y5\n','ascii'))     # y movement
p.printer.write(bytes('G1 Z5\n','ascii'))     # z movement

p.disconnect()