Why do the holes disappear

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

Why do the holes disappear

Nathaniel
I asked 5 questions in this, the one I care about most is #1.

There are a line of holes made with a cylinder+cube, profile of a "D" called "module smd_cell2(){".  This works all day long.

When I added a prism to a corner of the "D" called "module smd_cell(){", everything stopped working, including what wasn't covered with the prism.

Why doesn't difference(){ work when there is a polygon involved?  this is the smd_cell(); difference'd on the tray();  Each hovering block is supposed to have a corresponding difference(){ beneath it.  It works when I delete the "prism();" (a little lip needed for this storage tray.)  The holes are located in the bottom "module block_smd_cells1(){" and the hole that works is at the bottom of that stack.



$fn=25;

/*Several questions that I haven't found answers to anywhere.
1. why doesn't difference(){ work when there is a polygon involved?  this is the smd_cell(); difference'd on the tray();  Each hovering block is supposed to have a corresponding difference(){ beneath it.  it works when I delete the "prism();" (a little lip needed for this storage tray.)  The holes are located in the bottom "module block_smd_cells1(){" and the hole that works is at the bottom of that stack. */
resistor_tray1();

//this is the hulled one for reference.
translate([-.5*(tw)+(.5*smdh)+cww,0,2*th])
smd_cell();

translate([0,0,2*th])        
prism(smdh, .5*smdd, .5*smdd);


//This is it without the difference.  I don't understand why?
translate([.5*(tw)-(.5*smdh)-cww,0,2*th])
smd_cell2();

/* dissable/delete the lines 
        prism(smdh, .5*smdd, .5*smdd);
inside "module smd_cell(){" and there are holes again.  They aren't covered with the prism because it's only 1/2 as wide as the hull.  Is this a glitch or am I being a noob?

even though polygons are 2d; I don't think that's the problem, I tried this fix and just got garbage.  "http://forum.openscad.org/Problem-with-difference-method-td18421.html" if this was the problem the polygon would have issues and the hull would work... right?

2. How do you center=true a polyhedron?

3. How do I get calculations out of openscad?  If I need to build a box, add wheels, or determine if the widget will fit in the hole I need to know the hole is over 60 wide; I'm using very complicated math referencing a number that has been run through 15 other calculations before the final product.  Can I get openscad to tell me what is the number it's using right now especially when calculating my structural pyramids going through 2 cosigns, arcsigns, and the addition of 3 angles to calculate a hypotenus rod length.  LOL seems simple but not, and before you reccomend a calculator, many of these formulas are using 20+ compounded figures, I'd need to reenter everything into an excel to calculate and not be able to verify accuracy like openscad can.

4. I know there are easier ways to repeat a cell, the method is insane for 23 cells.  any thoughts on things like "module block_smd_cells1(){".  trying for a parametric repeating cells that size themselves for the space you're putting them into.  I can only get it to work for an either odd numbered, or even numbered branch (but not both).  There is something similar here "http://forum.openscad.org/staggered-honeycomb-td8242.html#a8252" but it's over my head at this point with some kind of a "for" function.  At this point what can I ask for but charity?
5. "WARNING: Object may not be a valid 2-manifold and may need repair!" when you delete/dissable the lines "difference(){" and it's corisponding, "}" inside the "module resistor_tray1(){".  Seriously that's all you have to do, I know 2-manifold has been dealt with elsewhere in the export function, this is a unique place for it to show up.
*/

//variables
gap=.01; //small gap between parts so they'll fit together
nt=5; //number of trays vertically
th=12; //tray height
cww=.8; //cell wall thickness

//Box
bw=.8; //box wall thickness
btod=180; //box total outside depth along y
btow=150; //box total outside width along x

//tray
tw=(.5*btow)-(1.5*bw)-(2*gap); //tray width
td=btod-gap-bw; //tray depth
lc=8; //lid catch or lip to slide the lid
hd=20; //handle depth
hh=8; //handle height
sh=2; //spring height

//resistor cell
nc=19; //number of cells only works with odd numbers
cw=62; //cell width along x
cd=10; //cell depth along y
pcd=(td-((nc+1)*cww))/nc; //parametric cell depth along y
tpcd=pcd+cww; //total depth
ch=th-cww; //cell height along z

//smd cell
smdh=(tw-cw)-(3*cww); //smd width and depth
smdd=pcd; //smd diameter

        
module prism(l, w, h){
    translate([-.5*smdh,0,th-cww])
    rotate([180,0,0])
       polyhedron(
               points=[[0,0,0], [l,0,0], [l,w,0], [0,w,0], [0,w,h], [l,w,h]],
               faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]
               );
       }

module tray(){
    translate([0,0,.5*th])
    cube([tw, td, th], center=true);
}

module resistor_tray1(){
difference(){
        tray();
        //block_resistor_cells1();
        block_smd_cells1();
        translate([.5*(tw)-(.5*smdh)-cww,0,cww])  //#0
        smd_cell2();
    }
}
    
module smd_cell(){
hull(){
    translate([0,0,1+(.5*smdd)])
    rotate([0,90,0])
        cylinder(h=smdh, d=smdd, center=true);
    difference(){
    translate([0,0,(th)-(.25*smdd)-cww])
        cube([smdh, smdd, .5*smdd],center=true);
        prism(smdh, .5*smdd, .5*smdd);
    }
    }
}

module smd_cell2(){
hull(){
    translate([0,0,1+(.5*smdd)])
    rotate([0,90,0])
        cylinder(h=smdh, d=smdd, center=true);
    translate([0,0,(th)-(.25*smdd)-cww])
        cube([smdh, smdd, .5*smdd],center=true);
}
}

module block_smd_cells1(){ //odd numbered cells only
    translate([-.5*(tw)+(.5*smdh)+cww,0,cww])  //#0
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww,(tpcd),cww])  //#1
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 2*(tpcd), cww])  //#2
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 3*(tpcd),cww])  //#3
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 4*(tpcd),cww])  //#4
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 5*(tpcd),cww])  //#5
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 6*(tpcd),cww])  //#6
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 7*(tpcd),cww])  //#7
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 8*(tpcd),cww])  //#8
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 9*(tpcd),cww])  //#9
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 10*(tpcd),cww])  //#10
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 11*(tpcd),cww])  //#11
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -(tpcd),cww])  //#12
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -2*(tpcd),cww])  //#13
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -3*(tpcd), cww])  //#14
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -4*(tpcd), cww])  //#15
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -5*(tpcd), cww])  //#16
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -6*(tpcd), cww])  //#17
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -7*(tpcd), cww])  //#18
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -8*(tpcd), cww])  //#19
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -9*(tpcd), cww])  //#20
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -10*(tpcd), cww])  //#21
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -11*(tpcd), cww])  //#22
    rotate([0,0,0])
        smd_cell();
        
    //the odd one as an example.
    translate([.5*(tw)+(.5*smdh)+cww,0,cww])  //#0
    rotate([0,0,0])
        smd_cell2();
}
Reply | Threaded
Open this post in threaded view
|

Re: Why do the holes disappear

MichaelAtOz
Administrator
This is the fixed code, I'll address the questions in the next post.
$fn=25;

/*Several questions that I haven't found answers to anywhere.
1. why doesn't difference(){ work when there is a polygon involved?  
this is the smd_cell(); difference'd on the tray();  
Each hovering block is supposed to have a corresponding difference(){ beneath it.  
it works when I delete the "prism();" (a little lip needed for this storage tray.)  
The holes are located in the bottom "module block_smd_cells1(){"
and the hole that works is at the bottom of that stack. */

resistor_tray1();

//this is the hulled one for reference.
translate([-.5*(tw)+(.5*smdh)+cww,0,2*th])
%smd_cell();

translate([0,0,2*th])        
%prism(smdh, .5*smdd, .5*smdd);

//This is it without the difference.  I don't understand why?
translate([.5*(tw)-(.5*smdh)-cww,0,2*th])
%smd_cell2();

/* dissable/delete the lines

        prism(smdh, .5*smdd, .5*smdd);
       
inside "module smd_cell(){" and there are holes again.  
They aren't covered with the prism because it's only 1/2 as wide as the hull.  
Is this a glitch or am I being a noob?

even though polygons are 2d; I don't think that's the problem,
I tried this fix and just got garbage.  
"http://forum.openscad.org/Problem-with-difference-method-td18421.html"
if this was the problem the polygon would have issues and the hull would work... right?

2. How do you center=true a polyhedron?

3. How do I get calculations out of openscad?  
If I need to build a box, add wheels, or determine if the widget will fit in the hole
I need to know the hole is over 60 wide;
I'm using very complicated math referencing a number that has been run
through 15 other calculations before the final product.  
Can I get openscad to tell me what is the number it's using right now
especially when calculating my structural pyramids going through 2 cosigns,
arcsigns, and the addition of 3 angles to calculate a hypotenus rod length.  
LOL seems simple but not, and before you reccomend a calculator,
many of these formulas are using 20+ compounded figures,
I'd need to reenter everything into an excel to calculate and not be able
to verify accuracy like openscad can.

4. I know there are easier ways to repeat a cell, the method is insane for 23 cells.  
any thoughts on things like "module block_smd_cells1(){".  trying for a parametric
repeating cells that size themselves for the space you're putting them into.
I can only get it to work for an either odd numbered, or even numbered branch
(but not both).  
There is something similar here
"http://forum.openscad.org/staggered-honeycomb-td8242.html#a8252"
but it's over my head at this point with some kind of a "for" function.  
At this point what can I ask for but charity?

5. "WARNING: Object may not be a valid 2-manifold and may need repair!"
when you delete/dissable the lines "difference(){" and it's corisponding, "}"
inside the "module resistor_tray1(){".  
Seriously that's all you have to do, I know 2-manifold has been dealt with elsewhere
in the export function, this is a unique place for it to show up.
*/

//variables
gap=.01; //small gap between parts so they'll fit together
nt=5; //number of trays vertically
th=12; //tray height
cww=.8; //cell wall thickness

//Box
bw=.8; //box wall thickness
btod=180; //box total outside depth along y
btow=150; //box total outside width along x

//tray
tw=(.5*btow)-(1.5*bw)-(2*gap); //tray width
td=btod-gap-bw; //tray depth
lc=8; //lid catch or lip to slide the lid
hd=20; //handle depth
hh=8; //handle height
sh=2; //spring height

//resistor cell
nc=19; //number of cells only works with odd numbers
cw=62; //cell width along x
cd=10; //cell depth along y
pcd=(td-((nc+1)*cww))/nc; //parametric cell depth along y
tpcd=pcd+cww; //total depth
ch=th-cww; //cell height along z

//smd cell
smdh=(tw-cw)-(3*cww); //smd width and depth
smdd=pcd; //smd diameter

       
module prism(l, w, h){
    translate([-.5*smdh,0,th-cww])
    rotate([180,0,0])
       polyhedron(
               points=[[0,0,0], [l,0,0], [l,w,0], [0,w,0], [0,w,h], [l,w,h]],
               faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]
               );
       }

module tray(){
    translate([0,0,.5*th])
    cube([tw, td, th], center=true);
}

module resistor_tray1(){
difference(){
        tray();
        translate([0,gap,gap]){  // slight offset so faces do not align
          //block_resistor_cells1();
          block_smd_cells1();
          #translate([.5*(tw)-(.5*smdh)-cww,0,cww])  //#0
          smd_cell2();
        }
    }
}
   
module smd_cell(){
hull(){
    translate([0,0,1+(.5*smdd)])
    rotate([0,90,0])
        cylinder(h=smdh, d=smdd, center=true);
    difference(){
    translate([0,0,(th)-(.25*smdd)-cww])
        cube([smdh, smdd, .5*smdd],center=true);
        prism(smdh, .5*smdd, .5*smdd);
    }
    }
}

module smd_cell2(){
hull(){
    translate([0,0,1+(.5*smdd)])
    rotate([0,90,0])
        cylinder(h=smdh, d=smdd, center=true);
    translate([0,0,(th)-(.25*smdd)-cww])
        cube([smdh, smdd, .5*smdd],center=true);
}
}

module block_smd_cells1(){ //odd numbered cells only
  #translate([0,-td/2+tpcd/2,0]) // move to -y end of tray, offset by 1/2 cell
    for(yOffset=[0:(td/tpcd)-1])
    translate([-.5*(tw)+(.5*smdh)+cww,yOffset*tpcd,cww])  //#0
    rotate([0,0,0])
        smd_cell();
  /*
    translate([-.5*(tw)+(.5*smdh)+cww,(tpcd),cww])  //#1
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 2*(tpcd), cww])  //#2
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 3*(tpcd),cww])  //#3
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 4*(tpcd),cww])  //#4
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 5*(tpcd),cww])  //#5
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 6*(tpcd),cww])  //#6
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 7*(tpcd),cww])  //#7
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 8*(tpcd),cww])  //#8
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 9*(tpcd),cww])  //#9
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 10*(tpcd),cww])  //#10
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, 11*(tpcd),cww])  //#11
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -(tpcd),cww])  //#12
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -2*(tpcd),cww])  //#13
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -3*(tpcd), cww])  //#14
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -4*(tpcd), cww])  //#15
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -5*(tpcd), cww])  //#16
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -6*(tpcd), cww])  //#17
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -7*(tpcd), cww])  //#18
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -8*(tpcd), cww])  //#19
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -9*(tpcd), cww])  //#20
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -10*(tpcd), cww])  //#21
    rotate([0,0,0])
        smd_cell();
    translate([-.5*(tw)+(.5*smdh)+cww, -11*(tpcd), cww])  //#22
    rotate([0,0,0])
        smd_cell();
    */
    //the odd one as an example.
    %translate([.5*(tw)+(.5*smdh)+cww,0,cww])  //#0
    rotate([0,0,0])
        smd_cell2();
}
Admin - PM me if you need anything,
or if I've done something stupid...

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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Why do the holes disappear

MichaelAtOz
Administrator
In reply to this post by Nathaniel
1. why doesn't difference(){ work

Lookup 'coincident faces', the face at the top if the prism was coincident to the top face of the tray, difference (& sometimes union & others) doesn't know whether that face should be still there (part of tray) or removed. I added a gap to let it know the prism was slightly above the tray and hence should be a good hole.

2. How do you center=true a polyhedron?

By knowings its size (you built it with numbers so you can calculate it) and translating dividing by two.

3. How do I get calculations out of openscad?

Presumable this relates to 2.
ATM you can't.
Since you built it you CAN calculate it into a variable.

4. I know there are easier ways to repeat a cell

See code.

5. "WARNING: Object may not be a valid 2-manifold and may need repair!"

This is related to 1. When it doesn't know whether a face is inside/outside a solid it can't make the solid 'waterproof'. In this case the problem was the cells outside the tray, just touching the side of the tray, I added another gap in the y to offset it a tiny bit so they were not touching.



Admin - PM me if you need anything,
or if I've done something stupid...

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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Why do the holes disappear

thehans
> 2. How do you center=true a polyhedron?

Well, since polyhedrons are not guaranteed symmetric like our other
primitives, "centering" has some ambiguity here.  Do you want to put
the center of the polyhedron's bounding box at the origin(what
MichaelAtOz already addressed), or do you want the polyhedron's center
of mass at the origin(harder)?

On Wed, Aug 16, 2017 at 5:12 PM, MichaelAtOz <[hidden email]> wrote:

> 1. why doesn't difference(){ work
>
> Lookup 'coincident faces', the face at the top if the prism was coincident
> to the top face of the tray, difference (& sometimes union & others) doesn't
> know whether that face should be still there (part of tray) or removed. I
> added a gap to let it know the prism was slightly above the tray and hence
> should be a good hole.
>
> 2. How do you center=true a polyhedron?
>
> By knowings its size (you built it with numbers so you can calculate it) and
> translating dividing by two.
>
> 3. How do I get calculations out of openscad?
>
> Presumable this relates to 2.
> ATM you can't.
> Since you built it you CAN calculate it into a variable.
>
> 4. I know there are easier ways to repeat a cell
>
> See code.
>
> 5. "WARNING: Object may not be a valid 2-manifold and may need repair!"
>
> This is related to 1. When it doesn't know whether a face is inside/outside
> a solid it can't make the solid 'waterproof'. In this case the problem was
> the cells outside the tray, just touching the side of the tray, I added
> another gap in the y to offset it a tiny bit so they were not touching.
>
>
>
>
>
>
>
> -----
> Admin - PM me if you need anything, or if I've done something stupid...
>
> 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.
>
> The TPP is no simple “trade agreement.”   Fight it! http://www.ourfairdeal.org/   time is running out!
> --
> View this message in context: http://forum.openscad.org/Why-do-the-holes-disappear-tp22070p22073.html
> 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 mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Why do the holes disappear

Nathaniel
In reply to this post by MichaelAtOz
Wow thank you!  Impressively simple, rather than the complex method I was using.

"3. How do I get calculations out of openscad?

Presumable this relates to 2.
ATM you can't.
Since you built it you CAN calculate it into a variable."

This isn't in reference to this project, I just figured since I was throwing a question out there? I'm building a 3d printer, with a frame out of carbon fiber rod (6mm od X 4mm id).  3d printing the joints that'll have a cylinder magnet (6x8mm) and a flat spring (for tolerance) inside, then gluing a magnet (4x10) inside the carbon rod.  In theory the rods will just snap into place to the latticework and if I've cut the rods to the EXACT right length the series of pyramids should be crazy strong, cheap, and bulletproof.  

I'm certainly stuck on the math, but grinding through a little at a time.  When it comes time to build I'll need the lengths of the rods.

The biggest problem, is the length of the rod is never specifically written in, it's a reference from the pyramid that came before, and the one that came before that. I originally was wanting to set the outside dimensions (x,y,z) and the inside cavity dimensions, and the dimensions just snap into place... But its looking like OpensCAD can't really do this?

You'll notice there are rods inside the tubes.




Reply | Threaded
Open this post in threaded view
|

Re: Why do the holes disappear

MichaelAtOz
Administrator
Have a look at this for inspiration https://www.thingiverse.com/thing:349943 
Admin - PM me if you need anything,
or if I've done something stupid...

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.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!