Hello,
I wanted to draw a curved bended round wire in OpenSCAD and could not find
an easy way for this.
First I was going to draw 2d curve in Inkscape, then export it to dxf, then
linear_extrude in OpenSCAD then make it smooth somehow.
So, finally, I was no able to solve the making it smooth part. Tried
minkowski in this way
/ minkowski() {
linear_extrude(height=1) import(file="wire1-43d.dxf");
sphere(r=0.5);
}/
and it makes OpenSCAD hang for a long time even on F5 preview (if use
$fn=100 it would hang forever and can even kill the computer itself).
Then I found this link which looks like what I wanted (even 2d would be
enough for me)
http://forum.openscad.org/smooth-3-D-curves-td7766.html
but it appeared that the shape path of the curve is generated by some kind
of math algorithm and I could not get an easy way from its code to generate
same thing from array of points and I want to draw complex curve shape in
Inkscape anyway.
So for now I am thinking of drawing this wire in blender (or export cubic
stl from OpenSCAD and smooth it in blender). But I though how naturally this
could be done if OpenSCAD could make linear_extrude along 2d (or 3d)
contour.
This could be either:
This would allow to draw not only round wires, but wires on any complex
shape.
I suppose, technically this could be easily implemented inside engine: this
would require making a series of normal linear_extrudes for each segment by
the height of the segment and then rotating extruded shape to follow segment
direction.
Also, this same thing could be implemented manually in OpenSCAD language, if
import dxf could return contour points like an array of 2d points to
manipulate inside OpenSCAD program. Probably, it already has this option?
thank's
--
View this message in context: http://forum.openscad.org/Linear-extrude-along-dxf-contour-or-alog-array-of-points-in-2d-3d-tp17424.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I think, what you want to do, is an general extrusion respectivly a sweep.
Programs like sketchup have build-in support for this, OpenSCAD has not.
There is no extrude() primitive, as general extrusion is not a well-defined
operation like linear_extrude or rotate_extrude().
The easiest (but also slow) way to do a sweep (for convex shapes) is using
hull() to connect short 'pieces' of the extruded shape placed along a given
tracjectory in 3D: http://www.thingiverse.com/thing:648813
Another way would be to use the sweep-libary, which is not defined for
arbitrary 2D-shapes, but can be easily extended to draw own shapes. The
mechanism to define trajectories is a bit tedious.
http://forum.openscad.org/Twisty-problem-with-scad-utils-quot-sweep-quot-td9775.html
If 2D extrusion is enough for you, you might want to try offset(),
extrude_2D()
circle(10, $fn=7);
module extrude_2D(d = 1)
{
difference()
{
offset(d)
children();
offset(-d)
children();
}
}
--
View this message in context: http://forum.openscad.org/Linear-extrude-along-dxf-contour-or-alog-array-of-points-in-2d-3d-tp17424p17426.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 2016-05-25 05:12, Parkinbot wrote:
I think, what you want to do, is an general extrusion respectivly a
sweep.
Programs like sketchup have build-in support for this, OpenSCAD has
not.
There is no extrude() primitive, as general extrusion is not a
well-defined
operation like linear_extrude or rotate_extrude().
Yes, I think for something like that a general sweep is required for
that. As you say. things can easily become less well defined than
linear_extrude, you need to control the orientation of the sweep profile
along the sweep path, and that might be tricky using only some basic
parameters.
Although not quite the same as general sweep, I have been playing with a
related (unreleased/experimental) feature in my AngelScript application.
It might provide some inspiration for OpenSCAD:
The general idea I had was to allow "extruding" from one general profile
(bottom) to another (top), where both of the profiles may themselves be
results of 2d boolean operations and possibly include holes. I'm not
sure what a proper name for this feature is, but for lack of a better
idea I call it "transform_extrude" for now. Here is a complete working
example:
// AngelScript CSG.
const double pi = 4.0atan(1.0);
double to_rad(double deg) { return pideg/180.0; } // to radians from
degrees
shape@ main_shape()
{
double ro = 12.5;
double ri = 0.9*ro;
shape2d@ bot_hole = scale(sx:1,sy:0.8)*circle(r:ri);
shape2d@ top_hole = rotate_z(to_rad(deg:15))
offset2d(sh:square(risqrt(2),center:true),r:3);
shape2d@ bot = difference2d(square(2ro,center:true),bot_hole) ;
shape2d@ top = difference2d(circle(rosqrt(2)),top_hole);
return transform_extrude(bottom:bot,top:translate(0,0,2*ro)*top);
}
void main()
{
shape@ obj = main_shape();
obj.write_xcsg(GetOutputFullPath('.xcsg'),secant_tolerance:0.001);
}
As you see, the bottom profile is a square with an elliptic hole, and
the top profile is a circle with a z-rotated square hole with filleted
corners. The final body is "transform_extrude"d from the bottom to the
translated top profile. It is possible to rotate either of the profiles
so they are no longer parallel planes in 3d, but it isn't done here. See
attached image of the result displayed with OpenSCAD.
Perhaps you want to consider similar things in OpenSCAD. It is perhaps
conceivable to extend this line of thought towards general sweep.
Carsten Arnholm
I think the operation is called "loft" in other CAD programs.
On 25 May 2016 at 09:16, arnholm@arnholm.org wrote:
On 2016-05-25 05:12, Parkinbot wrote:
I think, what you want to do, is an general extrusion respectivly a sweep.
Programs like sketchup have build-in support for this, OpenSCAD has not.
There is no extrude() primitive, as general extrusion is not a
well-defined
operation like linear_extrude or rotate_extrude().
Yes, I think for something like that a general sweep is required for that.
As you say. things can easily become less well defined than linear_extrude,
you need to control the orientation of the sweep profile along the sweep
path, and that might be tricky using only some basic parameters.
Although not quite the same as general sweep, I have been playing with a
related (unreleased/experimental) feature in my AngelScript application. It
might provide some inspiration for OpenSCAD:
The general idea I had was to allow "extruding" from one general profile
(bottom) to another (top), where both of the profiles may themselves be
results of 2d boolean operations and possibly include holes. I'm not sure
what a proper name for this feature is, but for lack of a better idea I
call it "transform_extrude" for now. Here is a complete working example:
// AngelScript CSG.
const double pi = 4.0atan(1.0);
double to_rad(double deg) { return pideg/180.0; } // to radians from
degrees
shape@ main_shape()
{
double ro = 12.5;
double ri = 0.9*ro;
shape2d@ bot_hole = scale(sx:1,sy:0.8)*circle(r:ri);
shape2d@ top_hole = rotate_z(to_rad(deg:15))
offset2d(sh:square(risqrt(2),center:true),r:3);
shape2d@ bot = difference2d(square(2ro,center:true),bot_hole) ;
shape2d@ top = difference2d(circle(rosqrt(2)),top_hole);
return transform_extrude(bottom:bot,top:translate(0,0,2*ro)*top);
}
void main()
{
shape@ obj = main_shape();
obj.write_xcsg(GetOutputFullPath('.xcsg'),secant_tolerance:0.001);
}
As you see, the bottom profile is a square with an elliptic hole, and the
top profile is a circle with a z-rotated square hole with filleted corners.
The final body is "transform_extrude"d from the bottom to the translated
top profile. It is possible to rotate either of the profiles so they are no
longer parallel planes in 3d, but it isn't done here. See attached image of
the result displayed with OpenSCAD.
Perhaps you want to consider similar things in OpenSCAD. It is perhaps
conceivable to extend this line of thought towards general sweep.
Carsten Arnholm
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org