[MakerBot] slice + gcode in sketchup

200 views
Skip to first unread message

Tobias Nurmiranta

unread,
Apr 21, 2010, 6:53:55 PM4/21/10
to MakerBot Operators
Hi.

While I'm waiting for the last stepper driver for my bot to arrive
(one was broken), I've been playing around a bit with sketchup. Has
anyone used any slice and gcode tool for sketchup? I found a slicer
plugin, and used the result as input to a small gcode-compiler I
started to write this evening.

Here I found the slicer:
http://www.cad-addict.com/2009/07/sketchup-plugins-slice-your-model.html

(in the forms for slicer I answered: slice-spacing 0.36m, slice-
thickness 0, then equalize spacing, leave selection hidden and no
flattened copy)

Then I added my really simple plugin to sketchup, which when tested
with a small cube outputted some gcode that Pleasant3d seemed to
accept. Has anyone done something similar and have any comments?

Would be nice to have skeinforge rewritten in ruby for sketchup. ;)

Well, just some thoughts,
Tobias


--- gcode.rb ---
require 'sketchup'

# Sketchup.send_action "showRubyPanel:"

UI.menu("PlugIns").add_item("Create G-code") { gcode }

def getfaces
model = Sketchup.active_model
entities = model.selection

entities.select do |e|
e.is_a?(Sketchup::Face)
end
end

def getgroupfaces
model = Sketchup.active_model
group = model.selection[0]

# get faces from the sliced model
(group.entities.to_a.map do |g|
g.entities.select do |e|
e.is_a?(Sketchup::Face)
end
end).flatten.reverse
end

def gcode
res = GCode::Header.clone

getgroupfaces.each do |e|
res << "(<layer>)\nM101\n"
e.outer_loop.vertices.each do |v|
res << "G1 X#{v.position.x.to_f} Y#{v.position.y.to_f}
Z#{v.position.z.to_f} F3300.0\n"
end
v = e.outer_loop.vertices[0]
res << "G1 X#{v.position.x.to_f} Y#{v.position.y.to_f}
Z#{v.position.z.to_f} F3300.0\n"
res << "M103\n(</layer>)\n"
end

filename = UI.savepanel("Save gcode", "", "x.gcode")
if filename
File.open(filename, "w") do |f|
f.write res
end
end
end

module GCode
Header = %Q{(homing routing)
M104 S220 T0 (Temperature to 220 celsius)
G21 (Metric FTW)
G90 (Absolute Positioning)
G92 X0 Y0 Z0 (You are now at 0,0,0)
(You have failed me for the last time, MakerBot)
G0 Z15 (Move up for test extrusion)
M108 S255 (Extruder speed = max)
M6 T0 (Wait for tool to heat up)
G04 P5000 (Wait 5 seconds)
M101 (Extruder on, forward)
G04 P5000 (Wait 5 seconds)
M103 (Extruder off)
M01 (The heater is warming up and will do a test extrusion. Click yes
after you have cleared the nozzle of the extrusion.)
G0 Z0 (Go back to zero.)
(end of start.)
(<creator> skeinforge June 8, 2009 </creator>)
(<extruderInitialization>)
G21
G90
G28
M103
M105
(<decimalPlacesCarried> 3 </decimalPlacesCarried>)
(<flowrateCubicMillimetersPerSecond> 4.473 </
flowrateCubicMillimetersPerSecond>)
(<layerThickness> 0.36 </layerThickness>)
(<extrusionPerimeterWidth> 0.468 </extrusionPerimeterWidth>)
(<outsideExtrudedFirst> True </outsideExtrudedFirst>)
(<feedrateMinute> 1560.0 </feedrateMinute>)
(<operatingFeedratePerSecond> 26.0 </operatingFeedratePerSecond>)
(<orbitalFeedratePerSecond> 26.0 </orbitalFeedratePerSecond>)
(<supportFlowrate> 255.0 </supportFlowrate)
(<travelFeedratePerSecond> 55.0 </travelFeedratePerSecond>)
(<extrusionWidth> 0.522 </extrusionWidth>)
(<fillInset> 0.4167 </fillInset>)
(<infillBridgeWidthOverExtrusionWidth> 1.0 </
infillBridgeWidthOverExtrusionWidth>)
(<procedureDone> carve </procedureDone>)
(<procedureDone> inset </procedureDone>)
(<procedureDone> fill </procedureDone>)
(<procedureDone> multiply </procedureDone>)
(<procedureDone> speed </procedureDone>)
(<procedureDone> raft /<procedureDone>)
(<procedureDone> comb </procedureDone>)
(<procedureDone> clip </procedureDone>)
(<procedureDone> oozebane </procedureDone>)
(<procedureDone> fillet </procedureDone>)
(<procedureDone> export </procedureDone>)
(</extruderInitialization>)
M108 S255.0
M104 S230.0
}

TAIL = %Q{(</extrusion>)
M103
M104 S0
(end of the file, cooldown routines)
M104 S0
G91
G1 X-18.8 Y18.85 Z10.0 F3300.0}
end

--
You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
To post to this group, send email to make...@googlegroups.com.
To unsubscribe from this group, send email to makerbot+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/makerbot?hl=en.

Cathal Garvey

unread,
Apr 21, 2010, 7:09:44 PM4/21/10
to make...@googlegroups.com

Wow! That's really awesome, especially combined with an STL import plugin!

Jordan Miller

unread,
Apr 22, 2010, 12:01:36 AM4/22/10
to make...@googlegroups.com
outstanding! please add to this wiki page with all your code and results:
http://wiki.makerbot.com/google-sketchup

be sure to link to it from the how-to-print page too!

jordan

Tobias Nurmiranta

unread,
Apr 22, 2010, 3:09:51 AM4/22/10
to MakerBot Operators
Thanks for the encouraging comment!

I'll do that when I've actually tried it out and verified that it
works. Think I need to learn a bit more about g-code, I guess I need
to study the operations carve and fill as a start. Anywhere I can find
a nice description on how the algorithms in skeinforge work, like a
youtube video of the different operations. :) :)

When I tried skeinforge on a small testcube I saw that it filled the
solid area with a pattern rather than solid, is that part of carve, or
the fill operation?

I have a lot to learn :)
Tobias
> > For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
> To post to this group, send email to make...@googlegroups.com.
> To unsubscribe from this group, send email to makerbot+u...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.

Cathal Garvey

unread,
Apr 22, 2010, 6:06:39 AM4/22/10
to make...@googlegroups.com
I believe that's in "Fill"; you select your pattern there, whether rectangular or hexagonal etc..

If you wanted a "complete" infill, you could set the periodicity of Diaphragm layers to 1, so that each layer is a Diaphragm and gets filled in totally. But, I find there's no need if you simply add another exterior shell and have a little infill to back it up. :)

I love that you're doing this, but prepare for a shock when you look at the skeinforge code. Apparently it's a malignant escher-like maze of code.
--
letters.cunningprojects.com
twitter.com/onetruecathal
twitter.com/labsfromfabs

Tobias Nurmiranta

unread,
Apr 22, 2010, 5:00:13 PM4/22/10
to MakerBot Operators
Hi. Thanks for the info!

I've put my code in development on http://tnlogy.googlecode.com/svn/trunk/slicer/
and now I've build my own slicer instead of using the plugin I wrote
about earlier. Sketchup has some convenient functionality for
intersection calculations. I added some code to scale the model to the
specified build area in the code.

But I guess the infill code will be a bit challenging, and I guess
that more advanced objects will get some strange results..
Tobia


On Apr 22, 12:06 pm, Cathal Garvey <cathalgar...@gmail.com> wrote:
> I believe that's in "Fill"; you select your pattern there, whether
> rectangular or hexagonal etc..
>
> If you wanted a "complete" infill, you could set the periodicity of
> Diaphragm layers to 1, so that each layer is a Diaphragm and gets filled in
> totally. But, I find there's no need if you simply add another exterior
> shell and have a little infill to back it up. :)
>
> I love that you're doing this, but prepare for a shock when you look at the
> skeinforge code. Apparently it's a malignant escher-like maze of code.
>
> > makerbot+u...@googlegroups.com<makerbot%2Bunsubscribe@googlegroups.c om>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/makerbot?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "MakerBot Operators" group.
> > > To post to this group, send email to make...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > makerbot+u...@googlegroups.com<makerbot%2Bunsubscribe@googlegroups.c om>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/makerbot?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "MakerBot Operators" group.
> > To post to this group, send email to make...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > makerbot+u...@googlegroups.com<makerbot%2Bunsubscribe@googlegroups.c om>
> > .

Andrew Plumb

unread,
Apr 22, 2010, 5:26:14 PM4/22/10
to make...@googlegroups.com
If you can figure out a way to step a line through each slice and find intersection points you could do a really simple fill algorithm by drawing fill lines between intersection points.

With each Z-layer 2D slice, alternate your line-intersect between X- and Y-axis perpendicular lines to build up the cross-hatch pattern.

Andrew.
--

"The future is already here. It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/

Tobias Nurmiranta

unread,
Apr 22, 2010, 7:19:18 PM4/22/10
to MakerBot Operators
That's a good idea, thanks. Rewrote some code to make the slicer work
in X, Y, and Z direction. So now I can slice a Z-plane in X-direction
and in that way get g-code for filling that Z-plane.

Will try to make it functional, right now it seems like sketchup dies
of complexity. :)

Tobias

On Apr 22, 11:26 pm, Andrew Plumb <and...@plumb.org> wrote:
> If you can figure out a way to step a line through each slice and find intersection points you could do a really simple fill algorithm by drawing fill lines between intersection points.
>
> With each Z-layer 2D slice, alternate your line-intersect between X- and Y-axis perpendicular lines to build up the cross-hatch pattern.
>
> Andrew.
>
> On 2010-04-22, at 5:00 PM, Tobias Nurmiranta wrote:
>
>
>
>
>
> > Hi. Thanks for the info!
>
> > I've put my code in development onhttp://tnlogy.googlecode.com/svn/trunk/slicer/
> >>> makerbot+u...@googlegroups.com<makerbot%2Bunsubscr...@googlegroups.c om>
> >>> .
> >>>>> For more options, visit this group athttp://
> >>> groups.google.com/group/makerbot?hl=en.
>
> >>>> --
> >>>> You received this message because you are subscribed to the Google Groups
> >>> "MakerBot Operators" group.
> >>>> To post to this group, send email to make...@googlegroups.com.
> >>>> To unsubscribe from this group, send email to
> >>> makerbot+u...@googlegroups.com<makerbot%2Bunsubscr...@googlegroups.c om>
> >>> .
> >>>> For more options, visit this group athttp://
> >>> groups.google.com/group/makerbot?hl=en.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "MakerBot Operators" group.
> >>> To post to this group, send email to make...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> makerbot+u...@googlegroups.com<makerbot%2Bunsubscr...@googlegroups.c om>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/makerbot?hl=en.
>
> >> --
> >> letters.cunningprojects.com
> >> twitter.com/onetruecathal
> >> twitter.com/labsfromfabs
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
> >> To post to this group, send email to make...@googlegroups.com.
> >> To unsubscribe from this group, send email to makerbot+u...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
> > To post to this group, send email to make...@googlegroups.com.
> > To unsubscribe from this group, send email to makerbot+u...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.
>
> --
>
> "The future is already here.  It's just not very evenly distributed" -- William Gibson
>
> Me:http://clothbot.com/wiki/
>
> --
> You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
> To post to this group, send email to make...@googlegroups.com.
> To unsubscribe from this group, send email to makerbot+u...@googlegroups.com. ...
>
> read more »

Revar Desmera

unread,
Apr 22, 2010, 8:32:40 PM4/22/10
to make...@googlegroups.com
By the way, I just released the STL importer/exporter I wrote for Sketchup. It supports both ASCII and binary formats. I'd add it to the Wiki, but I don't have an account there.

https://sourceforge.net/downloads/stl4su/

- Revar

Mark Cohen

unread,
May 4, 2010, 11:42:53 PM5/4/10
to MakerBot Operators
Hi,
I am having an issue where my extruder jams after about an hour on a
two hour print so I am thinking of slicing the part in two along the z
axis. Using the slice plugin what should I put into the parameters to
get an even split into two parts so that I can print them separately?
Thanks
On Apr 22, 8:32 pm, Revar Desmera <revar...@gmail.com> wrote:
> By the way, I just released the STL importer/exporter I wrote for Sketchup.  It supports both ASCII and binary formats.  I'd add it to the Wiki, but I don't have an account there.
>
>    https://sourceforge.net/downloads/stl4su/
>
>         - Revar
>
> On Apr 21, 2010, at 9:01 PM, Jordan Miller wrote:
>
>
>
>
>
> > outstanding! please add to this wiki page with all your code and results:
> >http://wiki.makerbot.com/google-sketchup
>
> > be sure to link to it from the how-to-print page too!
>
> > jordan
>
> > On Apr 21, 2010, at 6:53 PM, Tobias Nurmiranta wrote:
>
> >> Hi.
>
> >> While I'm waiting for the last stepper driver for my bot to arrive
> >> (one was broken), I've been playing around a bit with sketchup. Has
> >> anyone used any slice and gcode tool for sketchup? I found a slicer
> >>plugin, and used the result as input to a small gcode-compiler I
> >> started to write this evening.
>
> >> Here I found the slicer:
> >>http://www.cad-addict.com/2009/07/sketchup-plugins-slice-your-model.html
>
> >> (in the forms for slicer I answered: slice-spacing 0.36m, slice-
> >> thickness 0, then equalize spacing, leave selection hidden and no
> >> flattened copy)
>
> >> Then I added my really simplepluginto sketchup, which when tested
> >> For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
> > To post to this group, send email to make...@googlegroups.com.
> > To unsubscribe from this group, send email to makerbot+u...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "MakerBot Operators" group.
> To post to this group, send email to make...@googlegroups.com.
> To unsubscribe from this group, send email to makerbot+u...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/makerbot?hl=en.

Tobias Nurmiranta

unread,
May 11, 2010, 3:54:18 AM5/11/10
to MakerBot Operators
Hi. I think it is easier if you use the section plane tool in
sketchup. Look at this video, and I think you might get the idea.

http://www.youtube.com/watch?v=Ax9HY06PB8M

I guess it's best that you slice it manually at a good position in
your model. Tell me if you have a need for script, and I might be able
to help you.
Tobias
Reply all
Reply to author
Forward
0 new messages