Jump to content

Ultibaker script


greengecko

Recommended Posts

Posted · Ultibaker script

Hi,

I suggested this a while ago to Daid (but he did not respond, so he was either busy or did not think it was a good idea).

I had the idea especially because SteamEngine is so fast, that it would be great to have the ability to have different profiles during prints (at least switch the profile between layers). My idea was to define via a table of the following style:

file to.mm profile cubetest

ubakecsv

(= a csv file (e.g. created in Excel, germans be aware csv means comma seperated not ;" which is used in the german excel version and would not work)

The table defines which profile should be used at which model height (in mm).

As I did not write my own slicer (which is not an easy task I guess :wink: ) I took advantage of the steam engine speed. I sliced my models using different settings and saved them as different gcode files (e.g. cubetest1, cubetest2, cubetest3 for three different profiles using different infill settings, layer height etc.,) The table above defines then at which height (in mm) of the model which profile should be used. Then I run my R script (I use R because I am most familiar with it) and let the script combine them into a single file. In principle you could do it by hand but it needs some calculation if you need different layer heights.

The script is only partly intelligent. It checks only if there is no available layer and then searches for a common layer height where it can swap the profile.

An example would be, you start with the first layer at 0.3 (default in Cura) and then 0.2 mm as the layer height, but would like to change to a layer height of 0.3 mm at 1mm. This is not possible, because if you add 0.3+0.2+0.2+0.2 then you end up at 0.9mm or 1.1mm but not 1.0 mm height. So the script searches for the common layer height in the profiles (in this case 0.9, because 0.3 + 0.3 + 0.3 = 0.9) and switch at 0.9 mm to your new profile.

Otherwise it is pretty stupid, so if you want to print with 100% infill over a 5% infill then you probably will have trouble. Also other inconsistencies may occur.

It is still in a testing phase, it ran fine with my tests. Be aware that rapidly changing the layer height is not a good idea because of under/overextrusion so change only via modest steps. You are allowed to use as many profiles in one models as you want, so define intermediate steps and do not change layer height from 0.1 to 0.3 in one layer.

If there is some interest I am happy to provide a more elaborated manual and upload it to youmagine. I kind of back-engeneered Daids gcode, so if he decides to change his comments in Cura the script will be lost.....

Instructions:

Below I copy/pasted the R script. So to run this you need

 

  • [*]R (
http://cran.r-project.org/).

[*]Save the script as e.g. ultibaker.R and

[*]create a csv using the format above (Make sure you use exactly the same headings otherwise I will not work)

[*]Create different profiles of your model and save them in the same folder. Name them with consecutive numbers and the filename your provide in the csv file, e.g. frog1.gcode, frog2.gcode, frog3.gcode etc. Start with 1.

[*]Run the script (copy/paste it into the R console), it asks first for the folder and then for the csv file.

[*]This will create a new file called "file_baked.gcode" in your folder.

[*]Print your model using this new file

 

Obviously observe the printing as I provide no guarantee that it works . USE IT AT YOUR OWN RISK!

Happy to get feedback and even more happy if this idea will be at some stage integrated into Cura if agreed to be useful.

Cheers,

greengecko

############################script starts here############

path <-choose.dir(default = "", caption = "Select folder")

setwd(path)

settings <- read.csv(file.choose())

fn <- settings$file[1]

def.heights <- settings$to.mm

qualities <- settings$profile

nof <-length(unique(settings$profile))

files <-list()

lay.height<-NA

lay.tot<-NA

####### load files and determine layerheight

for (i in 1:nof)

{

con<-file(paste(fn,i,".gcode",sep=""))

files[] <-readLines(con)

close(con)

index <-grep("Layer height:",files[])

layerstr <- files[][index]

lay.height<-as.numeric(strsplit((gsub(";Basic settings: Layer height: ", "", layerstr))," ")[[1]][1])

#find model height

index <-grep(";total_layers=",files[])

layerstr <- files[][index]

lay.tot <-as.numeric( gsub(";total_layers=","",layerstr) )

}

#####################################################################

#lay.height=lay.height*1000

#####################################################################

# put together at layer heights

i<-1

xx<-files[]

a<-regexpr(" Z",xx)

hhh <- xx[a>10 & a<30]

ind <-a[a>10 & a<30]

hh<- as.numeric(substr(hhh,ind+2,ind+6))

model.def <- data.frame(seq=hh, l1=1)

for (i in 2:nof)

{

xx<-files[]

a<-regexpr(" Z",xx)

hhh <- xx[a>10 & a<30]

ind <-a[a>10 & a<30]

hh<- as.numeric(substr(hhh,ind+2,ind+6))

dl <-data.frame(seq=hh, x=1)

colnames(dl)[2] <- paste("l",i,sep="")

model.def <- merge(model.def,dl ,by="seq", all=T)

}

############################################

#define your model

############################################

#cat("Define your model from: 0 to",max(model.def$seq), "mm\n")

for (i in 1:(length(qualities)-1)) cat("To",def.heights,"mm : Quality",qualities,"\n")

#add the last quality for the virtual last layer+1

qualities <-c(qualities,qualities[length(qualities)])

######## adjust if not possible and find layer

chunksto=NA

getlayto=NA

getlayfrom[1]=0

for (i in 1:(length(qualities)-1))

{

#if (i==1) from=1 else from=which(model.def$seq==def.heights)

to = which(model.def$seq==def.heights)

dummyto<-model.def[1:to,c(1+qualities,1+qualities[i+1])]

chunksto<- max(which(dummyto[,1] == dummyto[,2]))

getlayto <- sum(model.def[1:chunksto,1+qualities],na.rm=T)

getlayfrom[i+1] <- sum(model.def[1:chunksto,1+qualities[i+1]],na.rm=T)

}

i=1

outfile<-character()

#get start code from first file

indexto <-min(grep(paste(";LAYER:",getlayto, sep=""),files[[qualities]]))

outfile <- files[[qualities]][1:indexto-1]

for (i in 2:(length(qualities)-2))

{

indexfrom <-min(grep(paste(";LAYER:",getlayfrom, sep=""),files[[qualities]]))

files[[qualities]][indexfrom] <- paste(files[[qualities]][indexfrom] ," QUALITY:",qualities," LAYER HEIGHT:",lay.height[qualities], sep="")

indexto <-min(grep(paste(";LAYER:",getlayto, sep=""),files[[qualities]]))

outfile <- c(outfile,files[[qualities]][indexfrom:indexto-1])

}

i=length(qualities)-1

indexfrom <-min(grep(paste(";LAYER:",getlayfrom, sep=""),files[[qualities]]))

files[[qualities]][indexfrom] <- paste(files[[qualities]][indexfrom] ," QUALITY:",qualities," LAYER HEIGHT:",lay.height[qualities], sep="")

indexto <- length(files[[qualities]])-1

outfile <- c(outfile,files[[qualities]][indexfrom:indexto-1])

con<-file(paste(fn,"_baked",".gcode",sep=""), open="w")

writeLines(outfile,con)

close(con)

 

############################script finishes here############

 

  • Link to post
    Share on other sites

    Posted · Ultibaker script

    I suggested this a while ago to Daid (but he did not respond, so he was either busy or did not think it was a good idea).

    I had the idea especially because SteamEngine is so fast, that it would be great to have the ability to have different profiles during prints

     

    Just so you know, I do think it's a good idea, but it's a UI nightmare at the same time ;-) see NetFabb, I think it can do this.

     

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.8 Stable released 🎉
        In the Cura 5.8 stable release, everyone can now tune their Z seams to look better than ever. Method series users get access to new material profiles, and the base Method model now has a printer profile, meaning the whole Method series is now supported in Cura!
        • 5 replies
      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Thanks
          • Like
        • 3 replies
    ×
    ×
    • Create New...