Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

For now you should send emails, people will see them, discuss@lists.openscad.org.

Help with difference of an object from an object generated by an module

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

Help with difference of an object from an object generated by an module

OpenSCAD mailing list-2
Hi,
I want to model a curved surface and create a hole in it (around the middle of it)
I have the code that should create this, but instead of difference, it seems to combine the objects.

Here is the code:
the module curvedBase does create a curved surface and rotate it in the horizontal plane
the module main should cut a cylinder from the surface generated by the curved module
The result I get are the 2 combined objects, not the difference

Any help is welcomed. 

========================================
$fn= 360;

w  = 40;      // width of rectangle
h  =   2;      // height of rectangle
l  =  90;      // length of chord of the curve
dh =   4;      // delta height of the curve

main();

module main(){
  difference(){
    curvedBase();
      
    translate([0,20,0])
      cylinder(  20,r1=10, d2=20, center=true);
  }
}

module curve(width, height, length, dh) {
    r = (pow(length/2, 2) + pow(dh, 2))/(2*dh);
    a = 2*asin((length/2)/r);
    translate([-(r -dh), 0, -width/2]) rotate([0, 0, -a/2])         rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
}

module curvedBase(){
  rotate([0,-90,90])
    curve(w, h, l, dh);
}



_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Help with difference of an object from an object generated by an module

lar3ry
I just copied your code and pasted it into OpenSCAD.
Here's a screenshot after a preview.




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

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Help with difference of an object from an object generated by an module

JordanBrown
In reply to this post by OpenSCAD mailing list-2
I too get the expected object with a hole in it.

Perhaps you have View/Thrown Together set?  That makes it look like the objects are combined instead of differenced.

A few comments on the program...

On 4/15/2021 8:52 PM, sorin vatasoiu via Discuss wrote:
$fn= 360;

360 is a lot for $fn.  In more complex models, that's likely to cost you a lot of time.

With $fn=360, your model has 412 facets and looks like this:


With $fa=1 and $fs=1, your model has 115 facets and looks like this:


You can see the difference on the screen.  My bet is that you can't see the difference in plastic.

Roughly, $fa controls the behavior of large circles and $fs controls the behavior of small circles.  The main body of the object ends up the same in either variation, with 1° segments.  The difference is in the hole, which has 360 segments in one variation and about 60 in the other.  Those 60 segments are each 1mm long.

      cylinder(  20,r1=10, d2=20, center=true);

You've asked for a cone with a bottom radius of 10 and a top diameter of 20.  It's unusual to specify a radius for one and a diameter for the other, but more importantly those are the same size so you could have just used r=10 or d=20.


_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Help with difference of an object from an object generated by an module

jon_bondy
I couldn't find references to $fn, $fa, and $fs on the OpenSCAD cheat
sheet: would it make sense to include them there?

On 4/16/2021 12:48 AM, Jordan Brown wrote:
> With $fa=1 and $fs=1, your model has 115 facets and looks like this:
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Help with difference of an object from an object generated by an module

lar3ry
In reply to this post by JordanBrown
JordanBrown wrote
>       cylinder(  20,r1=10, d2=20, center=true);

You've asked for a cone with a bottom radius of 10 and a top diameter of
20.  It's unusual to specify a radius for one and a diameter for the
other, but more importantly those are the same size so you could have
just used r=10 or d=20.
I tend to use radius or diameter interchangeably, depending on how I think of the way the part fits other parts, or the use of the part of the part itself. Yes, I might even use radius and diameter for opposite ends of a cylinder for the same reason. But yes, if they are the same size, it's better for readability to make them the same units.


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

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Help with difference of an object from an object generated by an module

jon_bondy
In reply to this post by jon_bondy
My bad: they are already present

On 4/16/2021 3:06 PM, jon wrote:
> I couldn't find references to $fn, $fa, and $fs on the OpenSCAD cheat
> sheet: would it make sense to include them there?
>
> On 4/16/2021 12:48 AM, Jordan Brown wrote:
>> With $fa=1 and $fs=1, your model has 115 facets and looks like this:
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]