Split .stl using difference??

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Split .stl using difference??

OpenSCAD mailing list-2
I want to print a .stl model (from Thingiverse) that is too long for my 3d printer bed. If I split it in 2 parts each half will fit on the print bed
I read in a forum post that you should be able to split a model by creating a shape that covers half of the model to split and using difference or intersection commands to create 2 halves.

However when I do the difference or intersection operation the remaining part of the .stl appears to have faces missing.

I'm a noob to opscad having moved from Fusion 360 so any help appreciated.

Here's my scad file

intersection(){
union(){import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");

translate([41.5,0,0]){
import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
}
}


union(){
translate([40,68,60]){
    color("green",0.5){
        cube ([44,120,140], center = true);
    }
}
translate([-39,68,60]){
    color("green",0.5){
        cube ([40,120,140], center = true);
    }
}


translate([.5,52.5,61]){
    color("blue",0.5){
        cube ([40.5,120,140], center = true);
    }
}
translate([81,52.5,61]){
    color("blue",0.5){
        cube ([40.5,120,140], center = true);
    }
}


translate([-2,-12,-20]){
    color("red",0.5){
        cylinder(30,10,10);
    }
}

translate([40,3,-20]){
    color("red",0.5){
        cylinder(30,10,10);
    }
}
}
}

and here's the link to the .stl file Download

Chris Johnson

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Split .stl using difference??

caggius
Try adding  ‘,convexity=10' to the imports (and you can loose a lot of the braces)

On 6 Mar 2021, at 16:48, Chris Johnson via Discuss <[hidden email]> wrote:

intersection(){
union(){import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");

translate([41.5,0,0]){
import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
}
}


union(){
translate([40,68,60]){
    color("green",0.5){
        cube ([44,120,140], center = true);
    }
}
translate([-39,68,60]){
    color("green",0.5){
        cube ([40,120,140], center = true);
    }
}


translate([.5,52.5,61]){
    color("blue",0.5){
        cube ([40.5,120,140], center = true);
    }
}
translate([81,52.5,61]){
    color("blue",0.5){
        cube ([40.5,120,140], center = true);
    }
}


translate([-2,-12,-20]){
    color("red",0.5){
        cylinder(30,10,10);
    }
}

translate([40,3,-20]){
    color("red",0.5){
        cylinder(30,10,10);
    }
}
}
}


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Split .stl using difference??

JordanBrown
On 3/6/2021 9:29 AM, Bob Carter wrote:
Try adding  ‘,convexity=10' to the imports (and you can loose a lot of the braces)

Yes, convexity is the problem here.

Indeed, many of the braces are unnecessary, but always always always indent.  If you're inside braces, indent.

For instance, for this segment:
intersection(){
union(){import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");

translate([41.5,0,0]){
import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
}
}
...

indent it like so:

intersection() {
    union() {
        import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");

        translate([41.5,0,0]) {
            import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
        }
    }
    ...
Use the indentation to show the structure; don't make the reader match up the braces.

Any particular reason that you're constructing your own dual dock by unioning two single docks, instead of using the dual dock provided?  Not that it matters to this question.


Strangely, the first time that I previewed this model, the intersection ... didn't.  It showed the original docks and the cubes for the intersection, and the intersection acted like a union.  Subsequent previews, including after restarting, got it right.  (Give or take the convexity issue.)  This is on 2021.01 on Windows.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Split .stl using difference??

MichaelAtOz
Administrator
In reply to this post by OpenSCAD mailing list-2
OpenSCAD mailing list-2 wrote
and here's the link to the .stl file Download
<https://cdn.thingiverse.com/assets/c3/6d/8b/8b/b5/2_Dual_Dock.stl>
Note that the STL has one self-intersection.

It could result in CGAL errors.

What thingi is that from?
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Split .stl using difference??

OpenSCAD mailing list-2
In reply to this post by OpenSCAD mailing list-2
Awesome, thanks! I'll give that a try.  I like the way you've used modules for the parts and processes.  It makes reading what its doing easier.  I used 2 single docks and then joined them so that I could make the centre wall thicker so that when I split the model asymmetrically there were some overlapping faces for glueing it together. And I used the cylinders to create jigsaw like sockets and parts to help lock the pieces together.  Probably overkill but it was good practice learning a new product

In the end the missing faces turned out to be due to the fact that I'd not pressed F6 to render.

Time to print... :-)

Chris Johnson


On Sun, 7 Mar 2021 at 08:01, Rogier Wolff <[hidden email]> wrote:
On Sat, Mar 06, 2021 at 04:48:52PM +0000, Chris Johnson via Discuss wrote:
> I want to print a .stl model (from Thingiverse) that is too long for my 3d
> printer bed. If I split it in 2 parts each half will fit on the print bed
> I read in a forum post that you should be able to split a model by
> creating a shape that covers half of the model to split and using
> difference or intersection commands to create 2 halves.
>
> However when I do the difference or intersection operation the remaining
> part of the .stl appears to have faces missing.
>
> I'm a noob to opscad having moved from Fusion 360 so any help appreciated.
>
> Here's my scad file

Here is mine:

----------------------

module obj ()
{
  import ("2_Dual_Dock.stl", convexity = 10);
}

module splitter ()
{
  translate ([-80,0,-5]) cube ([130,120,140]);
}

module p1 ()
{
  difference () {
    obj ();
    splitter ();
  }
}

module p2 ()
{
  intersection () {
    obj ();
    splitter ();
  }
}


translate ([0,  5,0]) p2 ();
translate ([0, -5,0]) p1 ();

--------------------------------------

        Roger.


>
> intersection(){
> union(){import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
>
> translate([41.5,0,0]){
> import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
> }
> }
>
>
> union(){
> translate([40,68,60]){
>     color("green",0.5){
>         cube ([44,120,140], center = true);
>     }
> }
> translate([-39,68,60]){
>     color("green",0.5){
>         cube ([40,120,140], center = true);
>     }
> }
>
>
> translate([.5,52.5,61]){
>     color("blue",0.5){
>         cube ([40.5,120,140], center = true);
>     }
> }
> translate([81,52.5,61]){
>     color("blue",0.5){
>         cube ([40.5,120,140], center = true);
>     }
> }
>
>
> translate([-2,-12,-20]){
>     color("red",0.5){
>         cylinder(30,10,10);
>     }
> }
>
> translate([40,3,-20]){
>     color("red",0.5){
>         cylinder(30,10,10);
>     }
> }
> }
> }
>
> and here's the link to the .stl file Download
> <https://cdn.thingiverse.com/assets/c3/6d/8b/8b/b5/2_Dual_Dock.stl>
>
> Chris Johnson

> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Split .stl using difference??

caggius
No the missing faces are due to the completely different tools that F5 and F6 use to render the view - I fell over this a few weeks back. For F5 Openscad uses OpenCSG and that needs to know how visually complex an object is and that is defined by the convexity of the object. But if you do not specify it the Convexity parameter defaults to 2 and in your case you had a complex object and there were more than 2 faces transitions that each ray crossed but OpenCSG simply did not render the faces at the back as it did not know they were there.

The convexity parameter specifies the maximum number of front sides (or back sides) a ray intersecting the object might penetrate. This parameter is only needed for correctly displaying the object in OpenCSG (F5) preview mode and has no effect on the polyhedron rendering (F6).

Cheers
Bob


On 7 Mar 2021, at 16:37, Chris Johnson via Discuss <[hidden email]> wrote:

Awesome, thanks! I'll give that a try.  I like the way you've used modules for the parts and processes.  It makes reading what its doing easier.  I used 2 single docks and then joined them so that I could make the centre wall thicker so that when I split the model asymmetrically there were some overlapping faces for glueing it together. And I used the cylinders to create jigsaw like sockets and parts to help lock the pieces together.  Probably overkill but it was good practice learning a new product

In the end the missing faces turned out to be due to the fact that I'd not pressed F6 to render.

Time to print... :-)

Chris Johnson


On Sun, 7 Mar 2021 at 08:01, Rogier Wolff <[hidden email]> wrote:
On Sat, Mar 06, 2021 at 04:48:52PM +0000, Chris Johnson via Discuss wrote:

> I want to print a .stl model (from Thingiverse) that is too long for my 3d
> printer bed. If I split it in 2 parts each half will fit on the print bed
> I read in a forum post that you should be able to split a model by
> creating a shape that covers half of the model to split and using
> difference or intersection commands to create 2 halves.
> 
> However when I do the difference or intersection operation the remaining
> part of the .stl appears to have faces missing.
> 
> I'm a noob to opscad having moved from Fusion 360 so any help appreciated.
> 
> Here's my scad file

Here is mine: 

----------------------

module obj ()
{
  import ("2_Dual_Dock.stl", convexity = 10);
}

module splitter ()
{
  translate ([-80,0,-5]) cube ([130,120,140]);
}

module p1 ()
{
  difference () {
    obj ();
    splitter ();
  }
}

module p2 ()
{
  intersection () {
    obj ();
    splitter ();
  }
}


translate ([0,  5,0]) p2 ();
translate ([0, -5,0]) p1 ();

--------------------------------------

        Roger. 


> 
> intersection(){
> union(){import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
> 
> translate([41.5,0,0]){
> import ("/Users/chrisjohnson/Downloads/1_Single_Dock.stl");
> }
> }
> 
> 
> union(){
> translate([40,68,60]){
>     color("green",0.5){
>         cube ([44,120,140], center = true);
>     }
> }
> translate([-39,68,60]){
>     color("green",0.5){
>         cube ([40,120,140], center = true);
>     }
> }
> 
> 
> translate([.5,52.5,61]){
>     color("blue",0.5){
>         cube ([40.5,120,140], center = true);
>     }
> }
> translate([81,52.5,61]){
>     color("blue",0.5){
>         cube ([40.5,120,140], center = true);
>     }
> }
> 
> 
> translate([-2,-12,-20]){
>     color("red",0.5){
>         cylinder(30,10,10);
>     }
> }
> 
> translate([40,3,-20]){
>     color("red",0.5){
>         cylinder(30,10,10);
>     }
> }
> }
> }
> 
> and here's the link to the .stl file Download
> <https://cdn.thingiverse.com/assets/c3/6d/8b/8b/b5/2_Dual_Dock.stl>
> 
> Chris Johnson

> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


-- 
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org