Quantcast

skin? or extrude circle to square

classic Classic list List threaded Threaded
5 messages Options
gcb
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

skin? or extrude circle to square

gcb
This post has NOT been accepted by the mailing list yet.
I try to use openscad for all my 'opensource' 3d parts. It's been a while since i've been out of touch, and now i am trying to create something that must change from a square to a circle.

I found some examples using skin() on https://github.com/openscad/list-comprehension-demos that might do the trick. But trying to run them show that my version does not understand a method used there "to_3d()". And searching for "openscad to_3d" is extremely useless. I only get results for things like "turn this 2d drawing to 3d" type of stuff. I can't even tell if that is a custom (utils?) method or native.

Anyway, i am trying to achieve something similar to https://grabcad.com/tutorials/extruding-from-square-to-round but with a controllable thickness skin.

What's the best way to go about it? Any suggestions?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: skin? or extrude circle to square

MichaelAtOz
Administrator
Welcome back to the forum. Your post is still flagged as "This post has NOT been accepted by the mailing list yet", so nobody gets it unless they look.
You need to subscribe to the mailing list, and CLICK THE LINK in the registration email (check your spam folder).

I've quoted your post for others to see.
gcb wrote
I try to use openscad for all my 'opensource' 3d parts. It's been a while since i've been out of touch, and now i am trying to create something that must change from a square to a circle.

I found some examples using skin() on https://github.com/openscad/list-comprehension-demos that might do the trick. But trying to run them show that my version does not understand a method used there "to_3d()". And searching for "openscad to_3d" is extremely useless. I only get results for things like "turn this 2d drawing to 3d" type of stuff. I can't even tell if that is a custom (utils?) method or native.

Anyway, i am trying to achieve something similar to https://grabcad.com/tutorials/extruding-from-square-to-round but with a controllable thickness skin.

What's the best way to go about it? Any suggestions?
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!
gcb
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: skin? or extrude circle to square

gcb
This post has NOT been accepted by the mailing list yet.
thanks. I will try to revalidate my email.

meanwhile, i think i solved whatever dumb thing i was doing with hull:

wallthickness=2; // thinest wall printable
largestpipe = 50; // diameter of the largest pipe mounth
fansize = 40; // 40mm fan
module conector(fansize,pipe,tall){
	difference(){
		color("teal") hull(){
			color("red")   translate([0,0,0] ) cylinder(1,pipe/2);
			color("green") translate([0,0,tall] ) cube([fansize,fansize,1],true);
		}
		color("blue") hull(){
			color("red")   translate([0,0,0] ) cylinder(1,pipe/2-wallthickness);
			color("green") translate([0,0,tall] ) cube([fansize-wallthickness,fansize-wallthickness,1],true);
		}
	}
}
conector(fansize,largestpipe, 30 );
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: skin? or extrude circle to square

shadowwynd
In reply to this post by gcb
The simplest way is hull:
(if making a 3d shape with hull, you need to start with 3d shapes, not 2D, hence linear_extrude)

hull()
{
    linear_extrude (0.1) square (100, center=true);
    translate ([0, 0, 60]) linear_extrude (0.1) circle (50);
}

This approach works for creating a manifold between any shapes, but it is incredibly ugly for shapes when you might want to see the "shift" from one to the other.  For instance, the code below does not make a twisted transition from shape to shape:

hull()
{
    linear_extrude (0.1) square (100, center=true);
    translate ([0, 0, 60]) rotate ([0, 0, 90]) linear_extrude (0.1) square (100, center=true);

}


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

http://www.thingiverse.com/thing:161646

This uses the concept of "tweening" between polygons.  For instance, to go between a square and a circle, start with a 360-sided polygon that looks like a circle, and a 360-sided polygon arranged so that most of the segments are colinear so that it looks like a square.  The shift from square to circle is then a weighted average of these two polygons arrays;  at A(100)B(0) you get A, at A(25)B(75) you get a shape that is 25% A, 75%B, etc.  The advantage of this approach is that you can do any shape, as long as you define the polygons beforehand (e.g. triangle to heart, etc.)  This builds lots of slices from A-->B.

http://www.thingiverse.com/thing:50363

This one uses the concept of superellipses - you can represent a square and a circle with the same mathematical function.  By adjust the parameter, you range from a pure square to a pure circle.  The downside is this approach only works for squares and circles.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: skin? or extrude circle to square

Ronaldo
@gcb,

The function to_3D either in skin.scad or sweep.scad is an embedding of a 2D polygon in 3D space. I could not find where it has been defined but it is something like:

function to_3D(p) = [for(pi=p) [pi[0],pi[1],0]];

@shadowwynd,

The hull() alternative is poor once it works only with convex shapes.
The second alternative is far better in shape and preserves non-convexities but it uses minkowski which is far slower.
The third is also good but works only with specific pair of shapes.

What distinguish skin.scad is its generality and the non use of boolean operations: it relies on building a polyhedron. Most of code and time of skin.scad is spent in "regularizing" the input shapes, that is, representing all the input shapes with the same number of points. The weak point of skin.scad is the way it generates the intermediate shapes by linear interpolation. Its strategy would have a gain if a spline interpolation, for instance, replaces the linear one.

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