Rectangle with one curved edge

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

Rectangle with one curved edge

John Tucker

I've embarrassed myself by asking stupid things on this list before;

I hope this isn't another. I'm trying to make a bit of a fiddly part.

It's to be a positive of an existing jaw which will later be a negative

(differenced) insert for a fit-over part.

 

The cross section is basically a rectangle with one side slightly

convex and the corners are slightly radiused. I had my first

printing (SLS) made without the convex face and the fit was

unacceptable. My question is: Is it possible to make an

intersection of an arc of a circle and a rectangle made by hulling

circles ?

 

Here's one of my attempts:

CX=9.525; // Cross section

CR=1; // Corner (fillet) Radius

X=CX-CR; // Cen to Cen of Circles

H=CX-9; // Cord height

R=(pow(CX,2)+(4*pow(H,2)))/(8*H);

$fn=64;

 

echo("radius= ",R);

 

module jawx(){

hull(){

translate([X/2-(1.15*H),X/2])circle(CR); // 1.15 empirical

translate([X/2-(1.15*H),-X/2])circle(CR);// to approx tang pt

translate([-X/2,X/2])circle(CR);

translate([-X/2,-X/2])circle(CR);

}

}

 

intersection(){ //

% linear_extrude(height=12) circle(r=R); // Extrude the disc

translate([2*X-(.5*H),0,0])

# linear_extrude(height=12) jawx(); // Extrude rect jaw x-section

}

 

I'm still using that crufty OpenSCAD version 2012.05.26 on Debian

3.2.86-1 i686 GNU/Linux.

 

TIA for any clues.


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

Re: Rectangle with one curved edge

MichaelAtOz
Administrator
Something like this:

intersection(){ //
    linear_extrude(height=12)
        circle(r=R); // Extrude the disc
    translate([2*X-(.5*H),-CX/2,0])
        cube([CX,CX,12]);
}
translate([2*X-(.5*H),0,0])
    linear_extrude(height=12)
    jawx(); // Extrude rect jaw x-section


Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


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: Rectangle with one curved edge

Ronaldo
In reply to this post by John Tucker
Don't be embarrassed. Even those who don't act makes mistakes.

Hull() doesn't help here.

To get a rectangle with rounded edges, intersect circles:

$fn = 120;
module arc_square(sx,sy,Rx,Ry) render()
intersection(){
    translate([-Rx+sx/2,0]) circle(Rx);
    translate([ Rx-sx/2,0]) circle(Rx);
    translate([0,-Ry+sy/2]) circle(Ry);
    translate([0, Ry-sy/2]) circle(Ry);
}   


To round vertices, use offset:

offset(r) square([a,b], center=true);



To get both, a little math is needed:

a = 30; // rectangle width
b = 20; // rectangle height
e = 2;  // rect. side bulge

Rx = e/2 + b*b/e/8;
Ry = e/2 + a*a/e/8; echo(Rx, Ry);
r = 3;
color("blue")
offset(r)
arc_square(a+2*e-2*r,b+2*e-2*r,Rx,Ry);
# translate([0,0,2]) square([a,b],center=true); // just to compare

/*
Using Pythagoras
R^2 = (R-e)^2 + (a/2)^2
0 = -2*e*R + e^2 + (a/2)^2
R = e/2 + (a/2)^2 / e / 2
*/


Now just linear_extrude() this polygon.

BTW, to make a cylinder you don't need linear_extrude().


2017-04-05 21:57 GMT-03:00 John Tucker <[hidden email]>:

I've embarrassed myself by asking stupid things on this list before;

I hope this isn't another. I'm trying to make a bit of a fiddly part.

It's to be a positive of an existing jaw which will later be a negative

(differenced) insert for a fit-over part.

 

The cross section is basically a rectangle with one side slightly

convex and the corners are slightly radiused. I had my first

printing (SLS) made without the convex face and the fit was

unacceptable. My question is: Is it possible to make an

intersection of an arc of a circle and a rectangle made by hulling

circles ?

 

Here's one of my attempts:

CX=9.525; // Cross section

CR=1; // Corner (fillet) Radius

X=CX-CR; // Cen to Cen of Circles

H=CX-9; // Cord height

R=(pow(CX,2)+(4*pow(H,2)))/(8*H);

$fn=64;

 

echo("radius= ",R);

 

module jawx(){

hull(){

translate([X/2-(1.15*H),X/2])circle(CR); // 1.15 empirical

translate([X/2-(1.15*H),-X/2])circle(CR);// to approx tang pt

translate([-X/2,X/2])circle(CR);

translate([-X/2,-X/2])circle(CR);

}

}

 

intersection(){ //

% linear_extrude(height=12) circle(r=R); // Extrude the disc

translate([2*X-(.5*H),0,0])

# linear_extrude(height=12) jawx(); // Extrude rect jaw x-section

}

 

I'm still using that crufty OpenSCAD version 2012.05.26 on Debian

3.2.86-1 i686 GNU/Linux.

 

TIA for any clues.


_______________________________________________
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: Rectangle with one curved edge

frankv
Minkowski() is a good way to radius corners.

On 6/04/2017 14:59, "Ronaldo Persiano" <[hidden email]> wrote:
Don't be embarrassed. Even those who don't act makes mistakes.

Hull() doesn't help here.

To get a rectangle with rounded edges, intersect circles:

$fn = 120;
module arc_square(sx,sy,Rx,Ry) render()
intersection(){
    translate([-Rx+sx/2,0]) circle(Rx);
    translate([ Rx-sx/2,0]) circle(Rx);
    translate([0,-Ry+sy/2]) circle(Ry);
    translate([0, Ry-sy/2]) circle(Ry);
}   


To round vertices, use offset:

offset(r) square([a,b], center=true);



To get both, a little math is needed:

a = 30; // rectangle width
b = 20; // rectangle height
e = 2;  // rect. side bulge

Rx = e/2 + b*b/e/8;
Ry = e/2 + a*a/e/8; echo(Rx, Ry);
r = 3;
color("blue")
offset(r)
arc_square(a+2*e-2*r,b+2*e-2*r,Rx,Ry);
# translate([0,0,2]) square([a,b],center=true); // just to compare

/*
Using Pythagoras
R^2 = (R-e)^2 + (a/2)^2
0 = -2*e*R + e^2 + (a/2)^2
R = e/2 + (a/2)^2 / e / 2
*/


Now just linear_extrude() this polygon.

BTW, to make a cylinder you don't need linear_extrude().


2017-04-05 21:57 GMT-03:00 John Tucker <[hidden email]>:

I've embarrassed myself by asking stupid things on this list before;

I hope this isn't another. I'm trying to make a bit of a fiddly part.

It's to be a positive of an existing jaw which will later be a negative

(differenced) insert for a fit-over part.

 

The cross section is basically a rectangle with one side slightly

convex and the corners are slightly radiused. I had my first

printing (SLS) made without the convex face and the fit was

unacceptable. My question is: Is it possible to make an

intersection of an arc of a circle and a rectangle made by hulling

circles ?

 

Here's one of my attempts:

CX=9.525; // Cross section

CR=1; // Corner (fillet) Radius

X=CX-CR; // Cen to Cen of Circles

H=CX-9; // Cord height

R=(pow(CX,2)+(4*pow(H,2)))/(8*H);

$fn=64;

 

echo("radius= ",R);

 

module jawx(){

hull(){

translate([X/2-(1.15*H),X/2])circle(CR); // 1.15 empirical

translate([X/2-(1.15*H),-X/2])circle(CR);// to approx tang pt

translate([-X/2,X/2])circle(CR);

translate([-X/2,-X/2])circle(CR);

}

}

 

intersection(){ //

% linear_extrude(height=12) circle(r=R); // Extrude the disc

translate([2*X-(.5*H),0,0])

# linear_extrude(height=12) jawx(); // Extrude rect jaw x-section

}

 

I'm still using that crufty OpenSCAD version 2012.05.26 on Debian

3.2.86-1 i686 GNU/Linux.

 

TIA for any clues.


_______________________________________________
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


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

Re: Rectangle with one curved edge

MichaelAtOz
Administrator
> one side slightly convex

> using that crufty OpenSCAD version 2012.05.26

Thus no offset()
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


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: Rectangle with one curved edge

Ronaldo
2017-04-06 0:33 GMT-03:00 MichaelAtOz <[hidden email]>:
> one side slightly convex

> using that crufty OpenSCAD version 2012.05.26

Thus no offset()

Does it have minkowski() ?

module offset(r) {
    very_big = 1e16; // something greater then the children size
    render()
    if(r>0)
        minkowski(){
            children();
            circle(r);
        }
    else
        difference(){
            square(very_big-1,center=true);
            minkowski(){
                difference(){
                    square(very_big,center=true);
                    children();
                }
                circle(-r);
            }
        }
}       
 


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

Re: Rectangle with one curved edge

nophead
Ronaldo,
  Why does your offset square example above have slightly curved edges? It should have straight edges and rounded corners and does when I try it.

On 6 April 2017 at 05:22, Ronaldo Persiano <[hidden email]> wrote:
2017-04-06 0:33 GMT-03:00 MichaelAtOz <[hidden email]>:
> one side slightly convex

> using that crufty OpenSCAD version 2012.05.26

Thus no offset()

Does it have minkowski() ?

module offset(r) {
    very_big = 1e16; // something greater then the children size
    render()
    if(r>0)
        minkowski(){
            children();
            circle(r);
        }
    else
        difference(){
            square(very_big-1,center=true);
            minkowski(){
                difference(){
                    square(very_big,center=true);
                    children();
                }
                circle(-r);
            }
        }
}       
 


_______________________________________________
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: Rectangle with one curved edge

John Tucker
In reply to this post by John Tucker

Just got the daily digest ... thanks to all who helped ...

Embarrassment is ok with me, it forces me to go further on my

own instead of looking for easy solutions. I'm in awe of

those of you on this forum that are so willing to help and

divert your attention from more serious things.

 

I'm on digest mode and will have to now work with the

suggestions all of you have contributed. Thanks again to all.

 


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

Re: Rectangle with one curved edge

Ronaldo
In reply to this post by nophead
2017-04-06 7:24 GMT-03:00 nop head <[hidden email]>:
Ronaldo,
  Why does your offset square example above have slightly curved edges? It should have straight edges and rounded corners and does when I try it.

 
You are right. The second image is a wrong image. That is what I should have include instead:




I should correct myself in the statement that hull() would not help here. It is possible to do it just with hull, without offset() or minkowski(). But the the math would be a little more complicate and I mention it here for completeness. The solution would be the intersection of the rounded edge rectangle with 4 big triangles with rounded vertices (a hull of 3 circles) well dimensioned and positioned.


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

Re: Rectangle with one curved edge

Ronaldo
In reply to this post by John Tucker
John,

One more detail about my solution. The assignment $fn=120; may not be adequate depending on the rectangle sizes you need. A better choice would be:

$fn = 100*max(Rx/sx,Ry/sy);

That assignment should be inside arc_square() just after intersection(){  . A value of $fn=32 might be enough for the circles inside module offset() .


2017-04-06 13:16 GMT-03:00 John Tucker <[hidden email]>:

Just got the daily digest ... thanks to all who helped ...

Embarrassment is ok with me, it forces me to go further on my

own instead of looking for easy solutions. I'm in awe of

those of you on this forum that are so willing to help and

divert your attention from more serious things.

 

I'm on digest mode and will have to now work with the

suggestions all of you have contributed. Thanks again to all.


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

Re: Rectangle with one curved edge

cbernhardt
In reply to this post by John Tucker
Do you have access to a CAD program that produces a DXF file?
The simple way would be to draw the profile in cad using your exact dimensions and then import it into OpenSCAD.
Reply | Threaded
Open this post in threaded view
|

Re: Rectangle with one curved edge

phormix
In reply to this post by John Tucker
Bit of a necropost here but I had a similar question with rounded corners and
though I'd share my formulae, which combine and outer/inner cube and
cylinders to create beveled corners

module beveled_rect(w,d,h,r){
  union() {
  translate([r,r,h/2]) cylinder(r = r, h = h, center = true);
  translate([w-r,r,h/2]) cylinder(r = r, h = h, center = true);
  translate([r,0, 0]) cube([w-(r*2),r,h]);

  translate([r,d-r,h/2]) cylinder(r = r, h = h, center = true);
  translate([w-r,d-r,h/2]) cylinder(r = r, h = h, center = true);
  translate([r,d-r, 0]) cube([w-(r*2),r,h]);
   
  translate([0, r, 0]) cube([w,d-(r*2),h]);
  }
}

module beveled_rect_bot(w,d,h,r){
  union() {
  translate([r,r,h/2]) cylinder(r = r, h = h, center = true);
  translate([w-r,r,h/2]) cylinder(r = r, h = h, center = true);
  translate([r,0, 0]) cube([w-(r*2),r,h]);
   
  translate([0, r, 0]) cube([w,d-r,h]);
  }
}

This of course focuses on bevelled/rounded corners, but one could just as
easily do the same logic with the whole edge.

As I make formulae etc I'll be posting them to my own wiki as well:

https://wiki.phormix.com/pub/index.php?title=OpenSCAD_Modules




--
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: Rectangle with one curved edge

lar3ry
In reply to this post by John Tucker
A 2 year old post, but it challenged me.

I started with a simple one. One side slightly convex...

module roundfrontcube() {
  intersection(){
    cylinder(d=200,h=20);
    translate([-30,-100,-.001])
    #cube([60,30,21]);
  }
}

Then I tried fillets and one side slightly convex...

intersection() {
#  fil_cube();
  translate([0,98,0])
#    cylinder(h=12,d=200);
}
module fil_cube() {
  union(){
    translate([-15.5,1,0])
    hull() {
      cylinder(h=12,r=2);
      translate([30,0,0])
        cylinder(h=12,r=2);
      translate([30,20,0])
        cylinder(h=12,r=2);
      translate([0,20,0])
        cylinder(h=12,r=2);
    }
    translate([-16,-4,0])
      cube([31,3,12]);
  }
}





--
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: Rectangle with one curved edge

adrianv
That solution has a non-smooth transition where the cylinder meets the
rounded cube---a small corner.  It may not really matter, since it's pretty
subtle, but it seems inelegant to me:

<http://forum.openscad.org/file/t2477/rect4.png>

I see three basic approaches.  One is to do something like previously
suggested with circles, for example.  Note that my solution below actually
directly sets the bulge amount.  But round2d() depends on offset().  

The Round-Anything library is here:
https://github.com/Irev-Dev/Round-Anything

// Draw a segment of a circle with specified length and height
module segment(length, height){
  r=(length*length+4*height*height)/8/height;
  intersection(){
    translate([0,(height+1)/2])
      square([length+2, height+1], center=true);
    translate([0,-r+height])circle(r=r);
  }
}

use <lib/Round-Anything/polyround.scad>

$fn=120;
bulge = 1;
cornerR = 1;
round2d(cornerR){
  square([10,5],center=true);
  translate([0,2.5])segment(10,bulge);
}

<http://forum.openscad.org/file/t2477/rect1.png>


Here's a second approach that avoids using offset() but instead relies on
polyRound, a function which applies a specified roundover radius at every
corner of a polygon.  

use <lib/Round-Anything/polyround.scad>

bulge=2;   // Actual bulge is less due to rounding to the inside
width=10;
height=5;
cornerR=1;
bulgeR=2*width;
rect = [[0,0,cornerR],
        [width,0,cornerR],
        [width,height,cornerR],
        [width/2,height+bulge,bulgeR],
        [0,height,cornerR]];
polygon(polyRound(rect,fn=20));

<http://forum.openscad.org/file/t2477/rect2.png>

Here's the third solution, my least favorite, using minkowski().   Of the
three, it took me the most fiddling to get this method working correctly,
and of course it runs slowly.  It would be a bit simpler if I didn't cut off
the curved ends of the cylinder with the intersection---it wasn't clear
whether rounded ends were OK or not.  

$fn=120;
bulge = 1;
cornerR = 1;
width = 10;
height = 5;
length = 10;
intersection(){
  translate([0,bulge/2,length/2])
    cube([width, height+bulge, length],center=true);
  render() minkowski()
  {
    sphere(r=cornerR, $fn=32);
    linear_extrude(height=length){
      square([width-2*cornerR,height-2*cornerR],center=true);
      translate([0,height/2-cornerR])segment(width-2*cornerR,bulge);
    }
  }
}

<http://forum.openscad.org/file/t2477/rect3.png>




--
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: Rectangle with one curved edge

lar3ry
I knew when I posted that it was a little kludgy, but figured all I had to do
was to refine the Y offset of the large cylinder to find the sweet spot.
Tried (trial and error) for a while, but could not get it exactly right.

I was hoping that someone would figure out a better way, and perhaps even a
way to use math to position everything.

Anyway, thanks a bunch for your solutions, and a special thank you for the
Round-Anything library. That's a keeper! All I have to do now is to figure
it out and get some practice.


adrianv wrote

> That solution has a non-smooth transition where the cylinder meets the
> rounded cube---a small corner.  It may not really matter, since it's
> pretty
> subtle, but it seems inelegant to me:
>
> &lt;http://forum.openscad.org/file/t2477/rect4.png&gt; 
>
> I see three basic approaches.  One is to do something like previously
> suggested with circles, for example.  Note that my solution below actually
> directly sets the bulge amount.  But round2d() depends on offset().  
>
> The Round-Anything library is here:
> https://github.com/Irev-Dev/Round-Anything





--
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: Rectangle with one curved edge

adrianv
lar3ry wrote
> I knew when I posted that it was a little kludgy, but figured all I had to
> do
> was to refine the Y offset of the large cylinder to find the sweet spot.
> Tried (trial and error) for a while, but could not get it exactly right.

I suspect that to get a smooth transition you would have needed to vary the
radius of your cylinder, not just its position.  That is, if you picked a
cylinder of a certain size the angle at which it connected with the
rectangle would probably be wrong for the rectangle's width.   The equations
for this seem like they are probably messy to work out, so I haven't
checked.  


> I was hoping that someone would figure out a better way, and perhaps even
> a
> way to use math to position everything.

Fortunately, it's not necessary to use much math to get good positioning.
In my opinion, when you have to resort to using a lot of math in the design,
and doing calculations for positioning things, it means something is wrong.
The math should be encapsulated into libraries and the designer should not
have to fuss with it.  Good solutions to most problems shouldn't require
using a lot of math at the high level.   They also shouldn't require trial
and error.  




--
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: Rectangle with one curved edge

lar3ry
adrianv wrote

> lar3ry wrote
>> I was hoping that someone would figure out a better way, and perhaps even
>> a way to use math to position everything.
>
> Fortunately, it's not necessary to use much math to get good positioning.
> In my opinion, when you have to resort to using a lot of math in the
> design,
> and doing calculations for positioning things, it means something is
> wrong.
> The math should be encapsulated into libraries and the designer should not
> have to fuss with it.  Good solutions to most problems shouldn't require
> using a lot of math at the high level.   They also shouldn't require trial
> and error.  

I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I guess
that may be (bad)habit-forming. I am also the product of a lot of years of
self-taught programming in everything from assembler on up.




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

_______________________________________________
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
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: Rectangle with one curved edge

adrianv
lar3ry wrote

>> The math should be encapsulated into libraries and the designer should
>> not
>> have to fuss with it.  Good solutions to most problems shouldn't require
>> using a lot of math at the high level.   They also shouldn't require
>> trial
>> and error.  
>
> I have been doing a lot of modification on existing STL files, and the
> easiest way I have found is to do pretty much all trial and error. I guess
> that may be (bad)habit-forming. I am also the product of a lot of years of
> self-taught programming in everything from assembler on up.

You're importing STL files into OpenSCAD and modifying them?   That seems
like it would be difficult to do in a nice fashion.  

But if you meant SCAD files then I think it relates to coding style.  I
started a discussion here about learning how to use OpenSCAD because I have
been struggling with these issues myself---both finding that I am doing
things by trial and error, and also finding that I can't read my own code a
day later.  And I think it has to do with writing code that is at too low a
level.  To avoid this, it's necessary to use libraries to abstract the
design.   But people here don't seem to be supportive of this approach.  
There's an idea that you should do everything directly on your own. Things
like obiscad's attach library or the BOSL library I think are important for
helping us to write code that is easier to read, modify and reuse.  




--
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: Rectangle with one curved edge

lar3ry
adrianv wrote

> lar3ry wrote
>> I have been doing a lot of modification on existing STL files, and the
>> easiest way I have found is to do pretty much all trial and error. I
>> guess
>> that may be (bad)habit-forming. I am also the product of a lot of years
>> of
>> self-taught programming in everything from assembler on up.
>
> You're importing STL files into OpenSCAD and modifying them?   That seems
> like it would be difficult to do in a nice fashion.  

Actually, I'm quite comfortable with the technique. I am curently in the
process of building a Hypercube Evolution printer, which is running. I want
to make some improvements, one of which is to use a piezo disk as a Z-stop
or bed probe. There is one available for the hotend mount, but I wanted to
make it an under-bed mount. So I took an aready-modified bed mount and used
union and difference to add some parts.
This was one of the more complex mods I've done.

Here's the STL and SCAD file. I have purposely left the congruent faces in
to show what's what in the preview.

Bed_Bracket_15_1-0_mod.stl
<http://forum.openscad.org/file/t2121/Bed_Bracket_15_1-0_mod.stl>  

$fn=60;

translate([30,20,0])
  piezomount();
main();

module main() {
  difference() {
    union() {
#      import("Bed_Bracket_15_1.0_mod.stl");
      translate([0,12,0])
        cylinder (h=10, d=30);
      translate([9,-3,0])
        cube([35,7.05,25]);
    }

    translate([0,12,0])
      cylinder (h=15, d=5);
    rotate([90,0,0])
      translate([18,8,-6])
        cylinder(h=10,d=3);
    rotate([90,0,0])
      translate([18,17,-6])
        cylinder(h=10,d=3);
  }
}

module piezomount () {
    union() {
      difference() {
        cylinder (h=4, d=30);
        cylinder (h=4, d=28);
      }
      difference () {
        cylinder(h=2, d=30);
        cylinder(h=2,d=25);
      }
    }
  }

Z_Piezo_Endstop_V3.png
<http://forum.openscad.org/file/t2121/Z_Piezo_Endstop_V3.png>  


> But if you meant SCAD files then I think it relates to coding style.  I
> started a discussion here about learning how to use OpenSCAD because I
> have
> been struggling with these issues myself---both finding that I am doing
> things by trial and error, and also finding that I can't read my own code
> a
> day later.  And I think it has to do with writing code that is at too low
> a
> level.  To avoid this, it's necessary to use libraries to abstract the
> design.   But people here don't seem to be supportive of this approach.  
> There's an idea that you should do everything directly on your own. Things
> like obiscad's attach library or the BOSL library I think are important
> for
> helping us to write code that is easier to read, modify and reuse.  

I know exactly what you mean. I always struggle with trying to achieve a
balance. I am definitely old-school in that I have a hard time wrapping my
mind around object oriented languages. Instead of using objects, I tend to
use subroutines and functions, but I do try to make re-usable ones, and
libraries are definitely a nice was to encapsulate groups of modules.

I LOVE the BOSL library, but haven't had a good look at the attach library.
I am going to get a lot of mileage out of the Round-Anything lib.



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

_______________________________________________
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
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: Rectangle with one curved edge

lar3ry
This post was updated on .
In reply to this post by adrianv
adrianv wrote
> lar3ry wrote
>> I have been doing a lot of modification on existing STL files, and the
>> easiest way I have found is to do pretty much all trial and error. I
>> guess
>> that may be (bad)habit-forming. I am also the product of a lot of years
>> of
>> self-taught programming in everything from assembler on up.
>
> You're importing STL files into OpenSCAD and modifying them?   That seems
> like it would be difficult to do in a nice fashion.  

Actually, I'm quite comfortable with the technique. I am curently in the
process of building a Hypercube Evolution printer, which is running. I want
to make some improvements, one of which is to use a piezo disk as a Z-stop
or bed probe. There is one available for the hotend mount, but I wanted to
make it an under-bed mount. So I took an aready-modified bed mount and used
union and difference to add some parts.
This was one of the more complex mods I've done.

Here's the STL and SCAD file. I have purposely left the congruent faces in
to show what's what in the preview.

Bed_Bracket_15_1-0_mod.stl
<http://forum.openscad.org/file/t2121/Bed_Bracket_15_1-0_mod.stl

$fn=60;

translate([30,20,0])
  piezomount();
main();

module main() {
  difference() {
    union() {
#      import("Bed_Bracket_15_1-0_mod.stl");
      translate([0,12,0])
        cylinder (h=10, d=30);
      translate([9,-3,0])
        cube([35,7.05,25]);
    }

    translate([0,12,0])
      cylinder (h=15, d=5);
    rotate([90,0,0])
      translate([18,8,-6])
        cylinder(h=10,d=3);
    rotate([90,0,0])
      translate([18,17,-6])
        cylinder(h=10,d=3);
  }
}

module piezomount () {
    union() {
      difference() {
        cylinder (h=4, d=30);
        cylinder (h=4, d=28);
      }
      difference () {
        cylinder(h=2, d=30);
        cylinder(h=2,d=25);
      }
    }
  }

Z_Piezo_Endstop_V3.png
<http://forum.openscad.org/file/t2121/Z_Piezo_Endstop_V3.png


> But if you meant SCAD files then I think it relates to coding style.  I
> started a discussion here about learning how to use OpenSCAD because I
> have
> been struggling with these issues myself---both finding that I am doing
> things by trial and error, and also finding that I can't read my own code
> a
> day later.  And I think it has to do with writing code that is at too low
> a
> level.  To avoid this, it's necessary to use libraries to abstract the
> design.   But people here don't seem to be supportive of this approach.  
> There's an idea that you should do everything directly on your own. Things
> like obiscad's attach library or the BOSL library I think are important
> for
> helping us to write code that is easier to read, modify and reuse.  

I know exactly what you mean. I always struggle with trying to achieve a
balance. I am definitely old-school in that I have a hard time wrapping my
mind around object oriented languages. Instead of using objects, I tend to
use subroutines and functions, but I do try to make re-usable ones, and
libraries are definitely a nice was to encapsulate groups of modules.

I LOVE the BOSL library, but haven't had a good look at the attach library.
I am going to get a lot of mileage out of the Round-Anything lib.



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

_______________________________________________
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





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

_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
12