Jump to content
Ultimaker Community of 3D Printing Experts
rmi

Cura <-> OpenSCAD integration

Recommended Posts

Hi,

I'm building a a somewhat unusual 3D printer. It uses 3 hotends at the moment, but the final goal is to have 6. While slowly exploring the world of dual/multiextrusion with my tools of choice, OpenSCAD and Cura, I wanted to have a better integration between both.

Current Issues:

* OpenSCAD exports only one mesh at a time. No big deal with single extrusion, but multi extrusion part often require changes to multiple meshes. Right now I'm using '*' or '!' in OpenSCAD to control which parts of a design are rendered and then exported. The whole process is error prone and tedious.

* Some of my designs require special slicer settings, like wall thickness, top/bottom layer etc. It happened a few times that I forget these changes when I had to print another part after a few weeks.

* Features like 'anti overhang mesh', 'support mesh', etc. are really hard to use as they require even more meshes to be exported for a single part.

I started to work on a Cura plugin some days ago (alpha stage at best right now), to see if it is possible to overcome some of these limitations. The Idea is to embed export and slicer settings as comments in OpenSCAD files and have a FileReader plugin that opens a file, scans for such comments, renders the objects via openscad and uses 'Per Object Settings' to override profile defaults on the imported objects.

The slicer settings are written back to the OpenSCAD file whenever G-Code is saved.

Examples:

 

/*cura{'ring(30, 20, 10)': {'extruder': 'toolchanger_0 #2', 'speed_print': 120}}*/

 

This would create the object 'ring(30, 20, 10)' from the imported SCAD file, assign the created mesh to extruder 0 and change the print speed to 120mm/s for this object.

 

/*cura{   'ring(10, 5, 6)': {   'extruder': 'toolchanger_0 #2',                         'top_bottom_thickness': 1.6},   'ring(15, 10, 5)': {'extruder': 'toolchanger_2 #2', 'wall_thickness': 1.6}}*/

 

Same here, but two meshes are created, assigned to different extruders and grouped into a single object.

Please note that there is no need to remember the syntax and slicer parameters. Adding a comment like

 

/*cura {'ring(10, 5, 6)': {}}*/

 

is sufficient to get it imported in Cura and all the settings are written once the G-Code is saved.

Clearly missing is a feature to keep track of the global state of the printer, like material assigned to extruders, loaded profil and unsaved changes to the profile and to show a warning after import.

One significant drawback is render time. OpenSCAD only allows one mesh to be exported, this means that internal mesh caches are not preserved between the render processes.

I haven't yet tested with anti_overhang or cutting_mesh an the like, but have no doubt that it could be used for this purpose as well.

If I sparked your interest, don't hold your breath. The plugin will take some time till release.

But I'm curious for your feedback. Am I missing obvious enhancements to the process?

While talking about and in case one of the devs just reads this. Some really useful settings are not available per model, most notable are all the "use extruder X for feature Y' options (like outer_wall_extruder).

  • Like 1

Share this post


Link to post
Share on other sites

just toyed a bit around with support_mesh and infill_mesh.

support_mesh allows you to selectively define areas that should have support structures.

infill_mesh allows you to overwrite change slicer settings for some parts of your model.

Consider the following part (view from bottom), eg. a simple mount plate that is fasten with four screws. The volume around the screws should be reinforced, 100% infill under the screw head and 75% infill in the volume around. The cross in the center should have support, but the ring around the screw holes not, because ...

mountbase.thumb.png.45c2e84a882ab8f3f9d65b904f3ff862.png

This requires a total of four meshes. One for the part, two to define to reinforcement and a forth for the selective support. See code and how the plugin could be used to define this complex arrangements of meshes:  

/*cura
{   'baseplate()': {   'extruder': 'toolchanger_0 #2',
                      'infill_sparse_density': 25},
   'reinforcment(d = 14)': {   'extruder': 'toolchanger_0 #2',
                               'infill_mesh': True,
                               'infill_mesh_order': 1,
                               'infill_sparse_density': 100,
                               'top_bottom_thickness': 0,
                               'wall_thickness': 0.0},
   'reinforcment(d = 24)': {   'extruder': 'toolchanger_0 #2',
                               'infill_mesh': True,
                               'infill_mesh_order': 2,
                               'infill_sparse_density': 50,
                               'top_bottom_thickness': 0,
                               'wall_thickness': 0.0},
   'support()': {'extruder': 'toolchanger_0 #2', 'support_mesh': True}}
*/
module relief(ri = 10, ro = 12, h = 3) {
   difference() {
       cylinder(r = ro, h = h);
       translate([0, 0, -0.01]) cylinder(r = ri, h = h + 0.02);
   }    
}
module nosupport(x = 50, y = 50, d = {
   centers(x, y, -0.01) relief(ri = d/2 + 4, ro = d/2 + ;
}
module centers(x, y, z = 0) {
   for(tx = [-x/2, x/2], ty = [-y/2, y/2])
       translate([tx, ty, z]) children();
}
module baseplate(x = 50, y = 50, d = 8, h = 10) {
   difference() {
       hull() centers(x, y) cylinder(r = 2 * d, h = h);
       centers(x, y, -0.01) cylinder(r = d/2, h = h + 0.02);
       support(x, y, d);
       nosupport(x, y);
   }
}
module reinforcment(x = 50, y = 50, d = 8, h = 10) {
  centers(x, y) cylinder(r = d/2, h = h); 
}
module support(x = 50, y = 50) {
   translate([0, 0, 2.5]) {
     cube([x - 10, 10, 5.01], center = true);
     cube([10, y - 10, 5.01], center = true);
   }
}
baseplate();
%color([0.5, 0, 0, 0.75]) reinforcment(d = 14, h = 10.2);
%color([0.5, 0.25, 0.25, 0.75]) reinforcment(d = 24, h = 10.1);
%color([0.75, 0.75, 1.0, 0.5]) support();

Cura Layer view, without further changes. The cross has support, but the rings not.

layer22.png.e1a5c87d94d69f81f24b27e04540abf6.png

A bit further to the top, the area close around the hole is 100% filled than 50% and than 25%, the default for the model.

Layer66.png.6130f88d1c3a5cbe158f43c29f26cf12.png

Edited by Guest

Share this post


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

Announcements

  • Our picks

    • Architect Design Contest | Vehicles.
      We're open for entries! - Design and submit your 3D designs of architectural entourage - vehicles - for a chance to win a large filament pack. Presenting an idea, an architectural design or something as big as an urban project isn't easy. A scaled model can really help to get your idea across.
        • Like
      • 24 replies
    • What The DfAM?
      I'm Steve Cox, an experienced engineer familiar with 3D printing. I wanted to share some DfAM guidelines with this community to help and make stronger parts.
      I'm also an Autodesk Certified Instructor for Fusion 360, so many of the images in ...
        • Thanks
        • Like
      • 22 replies
×

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!