michaelhauser
Posts: 5
Joined: Wed Jul 01, 2015 3:45 pm

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

Below is a Python script I wrote to go through the gcode generated by S3D and insert a flow control command (M108 Sxx) whenever the feed rate changes. The "FeedFlowRatio" multiplier can be adjusted to get the best result. This script is especially helpful on parts that have some areas that need to be printed more slowly than the rest of the part.

I have glanced at the source code for CubitMod, which is used with KISSlicer, and it's doing more sophisticated post-processing. First, it adjusts both flow rate and feed rate to work around the Cubex firmware's inability to handle fractional flow rates. That could be added to my script. Without it, the roundoff error can be problematic at very low flow rates. As I recall, CubitMod also adjusts prime/suck parameters (M227/M228) based on KISSlicer's heavily commented gcode. Unfortunately, it seems that S3D doesn't generate enough info (in gcode comments) for the post-processor to do that.

Code: Select all

#!/usr/bin/env python

"""
Massage gcode generated by Simplify3D for Cubex

s3d2cubex.py <FILE>

v0.1 by Michael Hauser
"""

import os
import re
import sys
import string

FeedFlowRatio = 0.006

if __name__ == '__main__':
	if len(sys.argv) < 2:
		sys.exit('usage: s3d2cubex.py <filename>')
	infilename = sys.argv[1]
	outfilename = '{}.flowfix{}'.format(os.path.splitext(infilename)[0],os.path.splitext(infilename)[1])
	readFeedRate = False
	previousFeedRate = 0.0
	
	with open(infilename) as infile:
		with open(outfilename,"w") as outfile:
			for line in infile:
				code = string.split(line)
				if code:
					if readFeedRate and code[0]=='G1' and code[-1][0] == 'F':
						feedRate = float(code[-1][1:])
						if feedRate != previousFeedRate:
							previousFeedRate = feedRate
							flowRate = feedRate * FeedFlowRatio
							outfile.write('M108 S{:.1f}\r\n'.format(flowRate))
						readFeedRate = False
					if code[0]=='M101':
						readFeedRate = True
					outfile.write(line)
					

rustel1972
Posts: 17
Joined: Sat Jul 25, 2015 7:06 am

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

hi michael, thanks for the script, adjusting the speed and m108 is like balancing rocks in a stream with the cubex.
can you give instruction on how/where to place the code?
do i delete the m108 line and add your code in?
michaelhauser
Posts: 5
Joined: Wed Jul 01, 2015 3:45 pm

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

Your S3D script doesn't change. You should use one of the ones included in the .fff files in this thread. My Python script is separate from S3D. It processes the gcode file after you "Save Toolpaths to Disk" from S3D. You must have Python installed on your computer to run it. I'm using a Mac but the script should work with any standard Python installation. If you don't already have Python installed, you can download and install it from http://python.org. To run the script on Mac or other Unix, use:

Code: Select all

./s3d2cubex.py <FILE>
or

Code: Select all

python s3d2cubex.py <FILE>
On Windows (after installing Python), use something like this (you might need to use full file paths for the script and path):

Code: Select all

C:\python27\python.exe s3d2cubex.py <FILE>
The script creates a file with the name as the input file but with ".flowfix" appended to the filename before the extension. That's the file with the inserted M108 codes.
MichaelHerron
Posts: 112
Joined: Mon Mar 16, 2015 2:36 pm

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

michaelhauser wrote:Your S3D script doesn't change. You should use one of the ones included in the .fff files in this thread. My Python script is separate from S3D. It processes the gcode file after you "Save Toolpaths to Disk" from S3D. You must have Python installed on your computer to run it. I'm using a Mac but the script should work with any standard Python installation. If you don't already have Python installed, you can download and install it from http://python.org. To run the script on Mac or other Unix, use:

Code: Select all

./s3d2cubex.py <FILE>
or

Code: Select all

python s3d2cubex.py <FILE>
On Windows (after installing Python), use something like this (you might need to use full file paths for the script and path):

Code: Select all

C:\python27\python.exe s3d2cubex.py <FILE>
The script creates a file with the name as the input file but with ".flowfix" appended to the filename before the extension. That's the file with the inserted M108 codes.
Excellent work! I haven't tried it yet, but hope to soon.
I can't help but wonder, though--is your script faster at post-processing than Simplify? If it is, i'm wondering if more of the post-processing could move to your python code. It takes a very long time for simplify to process complex models. (its super fast when it doesn't have to do the post processes.)

I'm not trying to assign tasks.. just wondering out loud.
the_dude
Posts: 21
Joined: Sat Jun 27, 2015 3:45 am

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

rustel1972 wrote:hey the_dude printed the nut and bolt in abs.. a reasonable print
0.2res

i attached the fff
I'm starting to think you FFF files are not working for 2 reasons..

1. Your printing in ABS, I'm in PLA.. all can really do is adjust the temp
2. your running a custom nozzle where as I have the original one.

Can you post a pic of the print you made?
logic1208
Posts: 12
Joined: Tue Apr 07, 2015 5:31 am

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

hi folks

really need help, i go cazy (ich dreh hier noch durch ;-)...

i have made a cubepro profile for z-glass ( t-glass like ).
everything works perfect ( the dimension is a bit to wide but ok ).
no when i export the file, convert with cube x, on the cupeprop printer comes the
error message: invalid file error.
i spend houres and houres to find the error, somtimes it works somtimes not?!

does any one have an idea?

( i tried: new usb stick, creat new profile, reinstall cubex, i have firmware 1.10/V2

thanks,

andy
Andy
Posts: 9
Joined: Wed Aug 26, 2015 8:18 pm

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

Hello here is Andy,
can some one give me the CubePro 1.10 firmware.
With the 1.11E the trick with the filament does not work.

Greetings Andy
miksane
Posts: 2
Joined: Thu Aug 27, 2015 9:50 am

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

I am having the same problem! Using version 1.12A, updated yesterday. "Invalid file"!
logic1208
Posts: 12
Joined: Tue Apr 07, 2015 5:31 am

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

@Andy

Heres the 1.10 V2 Firmware!

How do you want to downgrade?
Attachments
cubepro V1.10.zip
(6.17 MiB) Downloaded 385 times
rustel1972
Posts: 17
Joined: Sat Jul 25, 2015 7:06 am

Re: Tip of the Day 30 - Using 3DTouch, CubeX,CubePro and Rap

20150807_043346.jpg
hi the_dude, here is that nut and bolt pic. Yes my fff I set up for very small features, in abs, heated bed and .4 nozzle.. (cubexmachine) . the machine constantly work now! i have not adjusted the z hieght for 2 rolls of abs. no failures, support breaks away.

Return to “General Discussion and Tips”