Bending a flat 3D object.

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

Bending a flat 3D object.

Buk
This post was updated on .
I'm looking to create an object like this:
<http://forum.openscad.org/file/t2239/junk64.jpg

I can import a dxf of the 2D profile, and I can exdrude that to 3D, but I
cannot begin to see how to rotate or extrude or bend the tabs up?

I tried to visualise extruding the part to be thick enough that I could
carve away chunks to leave the shape I want, but that just seems like a
silly way to approach the problem.

Thoughts, pointers?

A 2D view might be clearer. I want to bend the component at the green lines:





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

_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Bending a flat 3D object.

Troberg
If it's going to be a sharp bend, I'd use some logic to cut it apart along
the green lines (make two objects which covers the bits to bend, then do an
intersection to get the bendy bits, and a difference to get the rest). Then,
just use rotate and union to put it together again, with bends in place.

I don't think there's an easier way, there is not "bend along this line"
command.



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

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

Re: Bending a flat 3D object.

Buk
Hm. I got this far pretty quickly:

$fa=0.1;
$fs=0.1;


intersection() {
    translate( [-25.5,-37] )
        import( "TA5[1-layer].dxf" );
        polygon( [
                [0,0],[0,5],[6,5],[6,-5],[0,0]
        ]);
    };

(which of course you won't be able to see as you don't have the dxf, but...
after a zillion attempts to rotate that about the appropriate axis, I'm
giving up on OpenSCAD.

I read that is very powerful.

Unfortunately, it very powerful in the same way that the alphabet is very
powerful.

Trouble is, I'm not Shakespeare or David Hockney.

Thanks for your time, I'm off to see if I can find something more at my
level.




--
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: Bending a flat 3D object.

Parkinbot
Are you willing to share the dxf?



--
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: Bending a flat 3D object.

cbernhardt
In reply to this post by Buk
I played with your project a little bit and came up with the picture below.
I traced over your picture in AutoCad and created three separate DXF files,
one for the main section and one for each "TAB".  Then it is just a matter
of bringing them into OpenSCAD, extruding them and then rotating and
translating the TABs so they fit together.  Not a nice smooth bend, but that
could be done.
<http://forum.openscad.org/file/t1309/bend.jpg>



--
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: Bending a flat 3D object.

Felipe Sanches
I think we all agree that openscad current lacks an expressive API for this kind of work. I would love to be able to "bend sheets of metal" on openscad as well, preferably using a piece of code that makes it obvious what's going on rather than nasty hacks.

2018-05-08 10:57 GMT+00:00 cbernhardt <[hidden email]>:
I played with your project a little bit and came up with the picture below.
I traced over your picture in AutoCad and created three separate DXF files,
one for the main section and one for each "TAB".  Then it is just a matter
of bringing them into OpenSCAD, extruding them and then rotating and
translating the TABs so they fit together.  Not a nice smooth bend, but that
could be done.
<http://forum.openscad.org/file/t1309/bend.jpg>



--
Sent from: http://forum.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: Bending a flat 3D object.

MathLover
Felipe Sanches wrote
> I think we all agree that openscad current lacks an expressive API for
> this
> kind of work. I would love to be able to "bend sheets of metal" on
> openscad
> as well, preferably using a piece of code that makes it obvious what's
> going on rather than nasty hacks.

I think you would need to work with actual "sheets" (2D geometry) and have
the bend command turn it into a bent 3D shape, where you would provide the
sheet thickness, bending line, bending angle, bending radius and (if you
really want to do it professionally) the distance to the neutral axis (which
is approximately at half the sheet thickness from the inside, but not
exactly.

My career as a draftsman started with a CAD program called CADAM, which had
this feature, but produced the results as a 2D view, as it was a "2.5D"
program.

Even so, you would probably have to cut the 2D shape up into pieces if you
want it to have more than one bend or if you want some parts along the
bending line to remain straight. You can the "union" these pieces together
after bending.



--
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: Bending a flat 3D object.

doug.moen
I've implemented bending in Curv as a non-affine coordinate transformation.
It isn't restricted to sheets.
You can bend cylinders, and that's quite useful for CAD.

OpenSCAD doesn't have non-affine transformations.
What makes this tricky is that you may need to add triangles.
If you think about how cylinders are represented in OpenSCAD, then
bending a cylinder along its length is impossible without adding triangles.

Once I implement STL import, you'll be able to import OpenSCAD models
into Curv, apply non-affine transformations like bend, then export them.
That's not a perfect solution, though, as you'd have to use an external tool.

It would be better if there were an open source library for performing
non-affine transformations on triangle meshes, or at least bends,
which could be called by OpenSCAD. Maybe OpenCascade supports bends?

If OpenSCAD allowed you to query the triangle mesh of a shape, from within the
language, then a bend operator could be written in OpenSCAD itself.

On 8 May 2018 at 08:13, MathLover <[hidden email]> wrote:
Felipe Sanches wrote
> I think we all agree that openscad current lacks an expressive API for
> this
> kind of work. I would love to be able to "bend sheets of metal" on
> openscad
> as well, preferably using a piece of code that makes it obvious what's
> going on rather than nasty hacks.

I think you would need to work with actual "sheets" (2D geometry) and have
the bend command turn it into a bent 3D shape, where you would provide the
sheet thickness, bending line, bending angle, bending radius and (if you
really want to do it professionally) the distance to the neutral axis (which
is approximately at half the sheet thickness from the inside, but not
exactly.

My career as a draftsman started with a CAD program called CADAM, which had
this feature, but produced the results as a 2D view, as it was a "2.5D"
program.

Even so, you would probably have to cut the 2D shape up into pieces if you
want it to have more than one bend or if you want some parts along the
bending line to remain straight. You can the "union" these pieces together
after bending.



--
Sent from: http://forum.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: Bending a flat 3D object.

cacb
On 08. mai 2018 18:35, doug moen wrote:
 > Maybe OpenCascade supports bends?

It does not, it is a b-rep CAD model.

 > If OpenSCAD allowed you to query the triangle mesh of a shape, from
 > within the language, then a bend operator could be written in
OpenSCAD itself.

Yes, but to do it, a couple of things in addition are required

1) a sufficiently dense triangle mesh. By default programs like OpenSCAD
will not create meshes that are immediately suitable for such bending
because there are usually too few triangles/vertices in the bend area.
You often have to re-mesh the model to make it sufficiently dense.

2) ability to transform the existing coordinates of a model.

As you cannot query or modify a model if is out of the question to do it
from within OpenSCAD. However, I have played with similar ideas in my
AngelCAD software, code example at
https://gist.github.com/arnholm/fadb3e6c7e38983643377569ca94d0b9

In this case the starting point is a straight pipe that could have been
made by OpenSCAD. The model is then re-meshed in another program to
create a much denser mesh. Finally the dense mesh pipe is imported and
"bent" 90 degrees by transforming the polyhedron coordinates in the bend
area.

Of course this particular model could have been created in OpenSCAD
using conventional methods, but it illustrates the general principle of
"bending" as was asked by the original poster.

Carsten Arnholm

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

Re: Bending a flat 3D object.

Parkinbot
Facing problems like this, we always end up in more or less the same feature
request. If there was a built-in import() *function*, we could write

mypolygon = import( "TA5[1-layer].dxf" );

and get a list of list of 2D-points in the case of a dxf. Then everything
can be handled in OpenSCAD more or less straight forward. Remeshing, mapping
into 3D, and bending extruding. In a more general approach we can write our
libs for discriminating positive and negative volumes, applying non-affine
transformations and much more.



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

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

Re: Bending a flat 3D object.

tp3
On 05/08/2018 11:31 PM, Parkinbot wrote:
> Facing problems like this, we always end up in more or less
> the same feature request.  >
Indeed. But always it's also completely ignored that there is
also an option to implement things in the OpenSCAD application.

ciao,
   Torsten.

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

Re: Bending a flat 3D object.

Parkinbot
What do you mean? Define the thing in OpenSCAD firsthand? Reinventing the
wheel is not always an option.


tp3 wrote
> Indeed. But always it's also completely ignored that there is
> also an option to implement things in the OpenSCAD application.





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

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

Re: Bending a flat 3D object.

tp3
On 05/09/2018 12:36 PM, Parkinbot wrote:
> What do you mean? Define the thing in OpenSCAD firsthand > Reinventing the wheel is not always an option.
>
Hm? I'm not sure I understand the question and what wheel
we are talking about.

What I mean is, that for example Doug said it would work if
there was support for non-affine transformations. Right now
CGAL does not seem to support the full range of possible
transformation matrices but it still might be possible to
implement this in OpenSCAD for the generic multmatrix() module.

So while that not solves the "I want access to the vertex
data" it would still allow the original problem to be solved.

And there's probably a lot of similar topics too, like
re-meshing / subdivision, linear_extrude with offset...

ciao,
   Torsten.

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

Re: Bending a flat 3D object.

Gadgetmind
In reply to this post by Parkinbot
On 08/05/18 22:31, Parkinbot wrote:
mypolygon = import( "TA5[1-layer].dxf" ); 

and get a list of list of 2D-points in the case of a dxf. 

I love OpenSCAD but it's a bit "black and white" in that either you can do it easily with built ins or you have to use point/polygon/polyhedron data, matrix/splines/etc transforms, and fire pretty much finished geometry into the "backend". If doing the latter, there are better packages around, and TBH adding all the required bending, smoothing and filleting to OpenSCAD is a larger job than I can ever see happening.

I can foresee a time when I create all geometry in (probably) Python and use OpenSCAD for binary ops (slicing for printing) which would be a shame.

No criticism of the devs, who've created something wonderful that I use daily, but it's hard to see an easy way to get OpenSCAD to the "next level".



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

Re: Bending a flat 3D object.

Parkinbot
In reply to this post by tp3
I don't see built-in non-affine transformations ever coming up in OpenSCAD -
just like there will be never a build-in sweep(). The implications for this
kind of operations are too large. Every second transformed object will throw
a CGAL exception, because people who don't know what they do will use it and
complain.
For me this is typical library stuff.
In contrast it would be so much easier to implement vertex access for
import, see what people will (and can) do with it, and then decide what of
this extra functionality can be brought into the App.




--
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: Bending a flat 3D object.

doug.moen
In reply to this post by Gadgetmind
@Gadgetmind said: it's hard to see an easy way to get OpenSCAD to the "next level".

The single "easy" thing we could do that would add the most value is to add the ability to query a shape and get back information like the bounding box, the triangle mesh. Then users could implement their own geometric operators, without the dev team and knowledge of C++ being the bottle neck for new geometric primitives.

Then there are also "hard" things we could do.

A few years ago, there was discussion on the mailing list about extending OpenSCAD to support implicit functions and signed distance fields, which is a different representation than triangle meshes, and which is much more powerful for certain applications. For example, you can implement operations like bending, smoothing and filleting in not very much code. There was an OpenSCAD clone called ImplicitCAD from 2011 that people were referencing, which uses implicit functions to represent geometry.

So I started to investigate this. Originally my idea was to extend OpenSCAD with this new geometry representation. Eventually, I realized that creating a hybrid geometry engine that supports both triangle meshes and implicit functions was going to be too much work, so I scaled back to just focus on signed distance fields.

So anyway, the technology works. I'm using Curv for my own 3D printing projects now. I use the bending, smoothing and filleting a lot. It's not backward compatible with OpenSCAD though, because again, I investigated that, and it was going to be way too much work. One reason is that you end up using a different programming style than OpenSCAD. You defined models using an exact mathematical representation. You can apply transformations like twist and bend, and the output is still an exact mathematical representation, you don't need to worry about where do the triangles go when you bend a cylinder. You just need to know math, like how to map from cartesian to polar coordinates (for a bend). That's what makes this representation easier to program with than triangle meshes. Triangles don't appear until the last step, when you export the model as an STL file. At that point, complicated algorithms written by experts must be used to fit triangles to your shape. But this complicated code is quite localized: knowledge about how to construct triangle meshes doesn't leak into every new primitive that you add to the library.

So that's my personal answer to the question of how do you implement fancy geometric operations like twist, bend, fillet and smooth.

So can this technology be added to OpenSCAD? It should be possible. Somebody could design a hybrid geometry engine that supports both triangle meshes and signed distance fields, and that converts between the two representations as necessary. I know of one other modelling tool that does this called IceSL, however it is not open source, so you can't look at the code to see how they did it.

At this point, I use Curv to create models (I'm more focussed on things like generative design and fractals, than on CAD). I use Curv to create the initial mesh, then I use tools like MeshLab and OpenSCAD to process the mesh for 3D printing. Curv has boolean operations, but it does not perform exact boolean operations on meshes: that's where OpenSCAD really shines.

On 9 May 2018 at 13:33, Gadgetmind <[hidden email]> wrote:
On 08/05/18 22:31, Parkinbot wrote:
mypolygon = import( "TA5[1-layer].dxf" ); 

and get a list of list of 2D-points in the case of a dxf. 

I love OpenSCAD but it's a bit "black and white" in that either you can do it easily with built ins or you have to use point/polygon/polyhedron data, matrix/splines/etc transforms, and fire pretty much finished geometry into the "backend". If doing the latter, there are better packages around, and TBH adding all the required bending, smoothing and filleting to OpenSCAD is a larger job than I can ever see happening.

I can foresee a time when I create all geometry in (probably) Python and use OpenSCAD for binary ops (slicing for printing) which would be a shame.

No criticism of the devs, who've created something wonderful that I use daily, but it's hard to see an easy way to get OpenSCAD to the "next level".



_______________________________________________
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
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Bending a flat 3D object.

tp3
In reply to this post by Gadgetmind
On 05/09/2018 07:33 PM, Gadgetmind wrote:
> No criticism of the devs, who've created something wonderful
> that I use daily, but it's hard to see an easy way to get > OpenSCAD to the "next level".
>
I can see lots of opportunities, like there is an still
incomplete pull request for linear_extrude() with offset.
Now let's just image we can give that offset parameter a
function as value. I believe that could open quite some
possibilities even if it's not quite a general extrusion
along an arbitrary 3d path.

ciao,
   Torsten.



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

Re: Bending a flat 3D object.

Peter Falke
Just print it flat, heat it in an oven, and bend it as desired.
Makes for a much stronger part, too.

2018-05-09 21:22 GMT+02:00 Torsten Paul <[hidden email]>:
On 05/09/2018 07:33 PM, Gadgetmind wrote:
No criticism of the devs, who've created something wonderful
that I use daily, but it's hard to see an easy way to get > OpenSCAD to the "next level".

I can see lots of opportunities, like there is an still
incomplete pull request for linear_extrude() with offset.
Now let's just image we can give that offset parameter a
function as value. I believe that could open quite some
possibilities even if it's not quite a general extrusion
along an arbitrary 3d path.

ciao,
  Torsten.




_______________________________________________
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