How to get a reasonable program flow for this situation?

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

How to get a reasonable program flow for this situation?

Troberg
I'm trying to design a box with dividers, to be lasercut, with tabs to fit
things together.

My plan is to put tabs on one of the parts which mesh, then then put them
together and difference(). to put the corresponding tabs/slots in the other
part.

Tre problem is that to do this, I woill need to put all the parts together,
and do most of the parts twice (one positive, one for the difference(). Once
I've done all the parts, due to the way OpenSCAD works, they'll be "lost". I
can't move them about to break it apart and get a template to cut. I need to
put them together, but once I do put it all together, I can't take it apart.

Is there a smart way to work this?



--
Sent from: http://forum.openscad.org/

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

Re: How to get a reasonable program flow for this situation?

William Adams-2
I worked up similar code for a CNC machine at: http://community.carbide3d.com/t/cnc-finger-joint-box/8880 and wound up extracting the parameters for the box from the JSON file and then working up a LuaLaTeX / METAPOST file which creates an SVG.

I'm now experimenting with doing something similar using tplang instead of lualatex/mp

You should be able to use my code to work out how to have an arrangement where the box is flattened out and arranged for cutting on the laser.

I'm trying to get all this put together as a Kickstarter --- drop me a line at [hidden email] and I'll see what I can work out which might help you.

William



On Mon, Feb 4, 2019 at 9:01 AM Troberg <[hidden email]> wrote:
I'm trying to design a box with dividers, to be lasercut, with tabs to fit
things together.

My plan is to put tabs on one of the parts which mesh, then then put them
together and difference(). to put the corresponding tabs/slots in the other
part.

Tre problem is that to do this, I woill need to put all the parts together,
and do most of the parts twice (one positive, one for the difference(). Once
I've done all the parts, due to the way OpenSCAD works, they'll be "lost". I
can't move them about to break it apart and get a template to cut. I need to
put them together, but once I do put it all together, I can't take it apart.

Is there a smart way to work this?



--
Sent from: http://forum.openscad.org/

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to get a reasonable program flow for this situation?

frankv
Typically, people use a variable to control the final position of the parts; if it's set to true, translate & rotate into the correct position for lasercutting, else if it's false leave the parts in their assembled positions.

On Mon, Feb 4, 2019 at 9:01 AM Troberg <[hidden email]> wrote:
I'm trying to design a box with dividers, to be lasercut, with tabs to fit
things together.

My plan is to put tabs on one of the parts which mesh, then then put them
together and difference(). to put the corresponding tabs/slots in the other
part.

Tre problem is that to do this, I woill need to put all the parts together,
and do most of the parts twice (one positive, one for the difference(). Once
I've done all the parts, due to the way OpenSCAD works, they'll be "lost". I
can't move them about to break it apart and get a template to cut. I need to
put them together, but once I do put it all together, I can't take it apart.

Is there a smart way to work this?


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

Re: How to get a reasonable program flow for this situation?

rew
On Tue, Feb 05, 2019 at 06:16:39AM +1300, Frank van der Hulst wrote:
> Typically, people use a variable to control the final position of the
> parts; if it's set to true, translate & rotate into the correct position
> for lasercutting, else if it's false leave the parts in their assembled
> positions.

That's the way I normally work too. Although I've switched from a
boolean to a "small integer". That way I can select any of a bunch of
configurations.

For another project I've made a module that will instantiate one of
the children and then subtract (difference) all of the following
children.

The children then need to start out in "assembled" locations. For the
lasercutting locations I rotate them back to planar in the "laser"
module.

if (show == 1) {
   assembled ();
}
if (show == 2) {
   alternative_assembly ();
}
if (show == 3) {
   laser ();
}
if (show == 4) {
   projection (cut=true) translate ([0,0,-mt/2]) laser ();
}

Actually, Openscad is much faster working with 3D objects. The
projection is really slow. So for viewing and adjusting the laser
configuration I use show=3, and then for exporting to DXF I use the
show=4. mt is material thickness.


        Roger.



>
> On Mon, Feb 4, 2019 at 9:01 AM Troberg <[hidden email]> wrote:
>
> > I'm trying to design a box with dividers, to be lasercut, with tabs to fit
> >> things together.
> >>
> >> My plan is to put tabs on one of the parts which mesh, then then put them
> >> together and difference(). to put the corresponding tabs/slots in the
> >> other
> >> part.
> >>
> >> Tre problem is that to do this, I woill need to put all the parts
> >> together,
> >> and do most of the parts twice (one positive, one for the difference().
> >> Once
> >> I've done all the parts, due to the way OpenSCAD works, they'll be
> >> "lost". I
> >> can't move them about to break it apart and get a template to cut. I need
> >> to
> >> put them together, but once I do put it all together, I can't take it
> >> apart.
> >>
> >> Is there a smart way to work this?
> >>
> >>

> _______________________________________________
> 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    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: How to get a reasonable program flow for this situation?

jgalak
In reply to this post by Troberg
You can also write a module that generates the positive part, and call it twice - once for the positive, once for the subtractive element for the negative.

On Mon, Feb 4, 2019 at 9:01 AM Troberg <[hidden email]> wrote:
I'm trying to design a box with dividers, to be lasercut, with tabs to fit
things together.

My plan is to put tabs on one of the parts which mesh, then then put them
together and difference(). to put the corresponding tabs/slots in the other
part.

Tre problem is that to do this, I woill need to put all the parts together,
and do most of the parts twice (one positive, one for the difference(). Once
I've done all the parts, due to the way OpenSCAD works, they'll be "lost". I
can't move them about to break it apart and get a template to cut. I need to
put them together, but once I do put it all together, I can't take it apart.

Is there a smart way to work this?



--
Sent from: http://forum.openscad.org/

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


--
Juliean Galak
[hidden email]

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

Re: How to get a reasonable program flow for this situation?

lostapathy
In reply to this post by rew
On 2/4/19 11:46 AM, Rogier Wolff wrote:
 <snip>
Actually, Openscad is much faster working with 3D objects. The
projection is really slow. So for viewing and adjusting the laser
configuration I use show=3, and then for exporting to DXF I use the 
show=4. mt is material thickness. 

For building up laser-cut parts, it can also be useful to draw all the components as 2d modules.  Then you can arrange them in 2d space for laser cutting and avoid the projection altogether, but still extrude them out for the as-assembled view.





	Roger. 



On Mon, Feb 4, 2019 at 9:01 AM Troberg [hidden email] wrote:

I'm trying to design a box with dividers, to be lasercut, with tabs to fit
things together.

My plan is to put tabs on one of the parts which mesh, then then put them
together and difference(). to put the corresponding tabs/slots in the
other
part.

Tre problem is that to do this, I woill need to put all the parts
together,
and do most of the parts twice (one positive, one for the difference().
Once
I've done all the parts, due to the way OpenSCAD works, they'll be
"lost". I
can't move them about to break it apart and get a template to cut. I need
to
put them together, but once I do put it all together, I can't take it
apart.

Is there a smart way to work this?



      
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to get a reasonable program flow for this situation?

ednisley
In reply to this post by rew
On 2/4/19 12:46 PM, Rogier Wolff wrote:
 > switched from a boolean to a "small integer"

I use strings tucked into Customizer variable:

Layout = "Show";           // [Show,Fit,Build]

Part = "Shell";           //
[Cradle,Shell,Clamp,ShellSections,M20,Interposer,Battery,Buttons]

… then near the bottom of the file …

if (Layout == "Show")

   if (Part == "Battery")
     BatteryShape();

   else if (Part == "Buttons")
     Buttons();

   else if (Part == "Interposer")
     InterposerShape(Embiggen = false);

   else if etc etc etc

if (Layout == "Build")

   if (Part == "Cradle")
     Cradle();

   else if (Part == "Clamp") {
     translate([0,0.7*ClampOA.y,0])
       difference() {
         translate([0,0,-Kerf/2])
           Clamp(Support = true);
         translate([0,0,-ClampOA.z])
           cube(2*ClampOA,center=true);
       }
     translate([0,-0.7*ClampOA.y,-0])
       difference() {
         translate([0,0,-Kerf/2])
           rotate([0,180,0])
             Clamp(Support = true);
         translate([0,0,-ClampOA.z])
           cube(2*ClampOA,center=true);
       }
   }

   else if etc etc etc

The "Show" layouts present each part, pretty much as-designed, with the
intent of letting me build each one in isolation.

The "Build" layouts consist of totally ad-hoc translates & rotates
arranging the pieces as needed on the printer platform.

The "Fit" layout tediously assembles everything more-or-less as it
should fit together in space, so as to see whether it does. The
motivation for a completely different chunk of code is a cross-check on
the dimensions, as debugging the Fit layout generally reveals a screwup
in a "Show" design. [sigh]

Suffices for my simple needs, anyhow.

--
Ed
https://softsolder.com

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

Re: How to get a reasonable program flow for this situation?

Ronaldo
In reply to this post by Troberg
I figure out the following scheme:
module assemble(miss=-1)
  if(miss<0 || miss>=nparts)
    for( i=[0:nparts-1] ) 
      rotate(rot[i])
        translate(pos[i])
          part(i) ;
  else {
    for(i=[0:1:miss-1]) linear_extrude(thick) bPart[i];
    for(i=[miss+1:1:nparts-1]) linear_extrude(thick) bPart[i];
  }
    
module part(i) 
  translate(-pos[i])
    rotate(-rot[i]) // transform back to xy plane
      difference() { 
        rotate(rot[i])
          translate(pos[i]) // transformed to assembly position
            linear_extrude(thick) bPart(i); 
        assemble(i);
      }

module bPart(part) {
  if(part==0)
      <basic definition of part 0 on xy plane> ;
  else if(part==1)
      <basic definition of part 0 on xy plane> ;
  ...
}

pos = [ pos0, pos1, pos2, ...];
rot = [ rot0, rot1, rot2, ...];

The module assemble() is able to assemble the full model (as default) or with one part missing whose index is its argument. The full assembly uses the parts cut using the assembly of basic parts.

The module part(i) computes the difference between the i-th basic part and the others basic parts in the assembly. That part is brought back to xy plane after cut by the other parts.

The module bPart(i) generates the 2D shape of the part i . That basic part definitions should have the extra material to be cut by the other basic parts in the assembly.

The vectors pos and rot store the translation vector and rotation vector to bring the linear_extrude() of the basic parts from the xy plane to their assembly positions.

I have not tried this scheme so ...

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

Re: How to get a reasonable program flow for this situation?

JordanBrown
In reply to this post by rew
On 2/4/2019 9:46 AM, Rogier Wolff wrote:
That's the way I normally work too. Although I've switched from a boolean to a "small integer". That way I can select any of a bunch of configurations.


I'm not sure whether it's valuable or just for fun, but I've had cases where I made it an animation, where it would animate back and forth between the assembled view and the as-printed view.  (Linear interpolation between the two translations and the two rotations, with small "pause" periods at each end.)

// Given a value and a table of value/position pairs, interpolate a
// position for that value.
// It seems like lookup() should do this sort of vector interpolation
// on its own, but it doesn't seem to.
function xyzinterp(v, table) =
    let (x= [for (i=[0:len(table)-1]) [table[i][0], table[i][1][0]]])
    let (y= [for (i=[0:len(table)-1]) [table[i][0], table[i][1][1]]])
    let (z= [for (i=[0:len(table)-1]) [table[i][0], table[i][1][2]]])
        [lookup(v, x), lookup(v, y), lookup(v,z)];

// Given a table of animation time values (from zero to one) and
// positions for each of those time values, translate the children
// to the appropriate position.
module atranslate(table) {
    translate(xyzinterp($t, table)) children();
}

// Given a table of animation time values (from zero to one) and
// rotations for each of those time values, rotate the children
// to the appropriate position.
module arotate(table) {
    rotate(xyzinterp($t, table)) children();
}

// Given a start point and an end point, translate the children
// from the start to the end and back in each animation cycle.
// Pause briefly at the start and end.
module a2translate(p1, p2) {
    atranslate([[0.05, p1], [0.45, p2], [0.55, p2], [0.95, p1]]) children();
}

// Given a start rotation and an end rotation, rotate the children
// from the start to the end and back in each animation cycle.
// Pause briefly at the start and end.
module a2rotate(p1, p2) {
    arotate([[0.05, p1], [0.45, p2], [0.55, p2], [0.95, p1]]) children();
}

Thus, given a couple of modules and positions and rotations for each view:

a2translate([0,0,0], [0,0,d]) a2rotate([0,0,0], [-90,0,0])
    color("SandyBrown") body();
a2translate([0,0,0], [w+5,0,door_t]) a2rotate([0,0,0], [-90,0,0])
    color("SandyBrown") doors();

(As it happens, the modules are positioned to "as assembled" at t=0 and "as printed" at t=0.5, but it could be the other way 'round.)


  


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

Re: How to get a reasonable program flow for this situation?

Troberg
In reply to this post by frankv
I use that a lot in other cases, such as when I want to make "exploded views"
showing disassembly.

The problem here, is that the placement of a part is part of making other
parts. I place a part to "poke holes" in other parts using difference(), to
ensure a correct fit. Now, say that this part pokes holes in three other
parts, I can't now move them, because they aren't available as objects
anymore.

Sure, I could do the math, calculate every position of every tab so that it
lines up, but it's a lot more work, and it makes for a much more error prone
process, likely to waste expensive material.



--
Sent from: http://forum.openscad.org/

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

Re: How to get a reasonable program flow for this situation?

nophead
Not sure I understand your issue. Define the parts with the difference as modules to make them objects that you can move with their holes. Define the holes as modules so that you can subtract them from several parts. 

If you want to do different things with the holes, like drill them and add fasteners then define the positions of the holes as a module that positions its children.




On Tue, 5 Feb 2019 at 09:41, Troberg <[hidden email]> wrote:
I use that a lot in other cases, such as when I want to make "exploded views"
showing disassembly.

The problem here, is that the placement of a part is part of making other
parts. I place a part to "poke holes" in other parts using difference(), to
ensure a correct fit. Now, say that this part pokes holes in three other
parts, I can't now move them, because they aren't available as objects
anymore.

Sure, I could do the math, calculate every position of every tab so that it
lines up, but it's a lot more work, and it makes for a much more error prone
process, likely to waste expensive material.



--
Sent from: http://forum.openscad.org/

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to get a reasonable program flow for this situation?

Troberg
That would work, but still not as neat as just letting the parts "shape each
other".



--
Sent from: http://forum.openscad.org/

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

Re: How to get a reasonable program flow for this situation?

JordanBrown

Could you give a concrete example (modeled however you can) of the kind of situation you're facing?



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

Re: How to get a reasonable program flow for this situation?

nophead
My guiding principal is to avoid defining the same information more than once. I.e. a repeated expression becomes a named constant if local, else a function. A position either a named constant or a module. That way everything changes together and things don't get out of step.

On Tue, 5 Feb 2019 at 15:20, Jordan Brown <[hidden email]> wrote:

Could you give a concrete example (modeled however you can) of the kind of situation you're facing?


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to get a reasonable program flow for this situation?

Ronaldo
Well, I revised the scheme I had proposed and it is wrong. However, the behind ideas are worth of considering.

I have attached a code that follows a (big) revision of those ideas. The following image give an account of the results.

BoxCutting.PNG
The set of parts at left is the design of the parts in laser cut plan position with their tabs but without the "voids".
The center set shows the parts after have been processed by cutting the matching "voids" for the tabs. This process is automated.
At right, the final assembly of the box.

I hope it helps.

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

CuttingPieces.scad (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get a reasonable program flow for this situation?

Troberg
Yep, that's somewhat what I was looking for. It does get kind of awkward,
though, but I haven't found a neater way to do it, especially when you are
doing boxies with lots of dividers, and not all shapes being square.



--
Sent from: http://forum.openscad.org/

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