discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Tool idea for matching complex curves

BC
Bob Carlson
Fri, Sep 20, 2024 12:29 AM

Is there a tool like this already out there? I played around a little with InkScape, but didn’t see an easy way to use it.

I keep facing the problem of creating a curve in OpenSCAD that matches the one on a physical item. Bézier curves seems like a likely way to represent the curve but I have never used them because it just seemed like a LOT of trial and error was the only way. I have thought about what a tool would look like and here is the outline of it.

You have a 2D canvas, XY axes. You can import a JPG of the curve you need to match.

The JPG can be scaled up or down so that the physical measurements you made of the object match the scale on the canvas.

You can click on the canvas and create 1 or more Bézier curves on the canvas and match them to the curve(s) on your JPG. Multiple curves could be used for complex shapes.

The curve parameters could then be copied and pasted into the OpenSCAD code. Ideally it would even produce the code itself.

It seems like this could be a tool built into the SCAD code, a kind of Bezier sketchpad.

Thoughts?

Is there a tool like this already out there? I played around a little with InkScape, but didn’t see an easy way to use it. I keep facing the problem of creating a curve in OpenSCAD that matches the one on a physical item. Bézier curves seems like a likely way to represent the curve but I have never used them because it just seemed like a LOT of trial and error was the only way. I have thought about what a tool would look like and here is the outline of it. You have a 2D canvas, XY axes. You can import a JPG of the curve you need to match. The JPG can be scaled up or down so that the physical measurements you made of the object match the scale on the canvas. You can click on the canvas and create 1 or more Bézier curves on the canvas and match them to the curve(s) on your JPG. Multiple curves could be used for complex shapes. The curve parameters could then be copied and pasted into the OpenSCAD code. Ideally it would even produce the code itself. It seems like this could be a tool built into the SCAD code, a kind of Bezier sketchpad. Thoughts?
JG
Jonathan Gilbert
Fri, Sep 20, 2024 12:41 AM

You could look at something like GiMP or Illustrator to convert a bitmap to
an SVG, and import that into OpenSCAD, but I'm pretty sure that process
will look a lot like the wiki-suggested route of using Inkscape.

In your thought above, you return back to ultimately working with a Bezier;
is that what you're looking for, or did you want to end up with a shape or
path to create a shape? Seems like if it's the former and you want a Bezier
curve, might just be worth it to bite down and trial-and-error till you're
comfy with them; and if it's the latter, then working from an SVG is what
you want?  Unless I'm misinterpreting what you're proposing above?

On Thu, Sep 19, 2024 at 5:29 PM Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

Is there a tool like this already out there? I played around a little with
InkScape, but didn’t see an easy way to use it.

I keep facing the problem of creating a curve in OpenSCAD that matches the
one on a physical item. Bézier curves seems like a likely way to represent
the curve but I have never used them because it just seemed like a LOT of
trial and error was the only way. I have thought about what a tool would
look like and here is the outline of it.

You have a 2D canvas, XY axes. You can import a JPG of the curve you need
to match.

The JPG can be scaled up or down so that the physical measurements you
made of the object match the scale on the canvas.

You can click on the canvas and create 1 or more Bézier curves on the
canvas and match them to the curve(s) on your JPG. Multiple curves could be
used for complex shapes.

The curve parameters could then be copied and pasted into the OpenSCAD
code. Ideally it would even produce the code itself.

It seems like this could be a tool built into the SCAD code, a kind of
Bezier sketchpad.

Thoughts?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

You could look at something like GiMP or Illustrator to convert a bitmap to an SVG, and import that into OpenSCAD, but I'm pretty sure that process will look a lot like the wiki-suggested route of using Inkscape. In your thought above, you return back to ultimately working with a Bezier; is that what you're looking for, or did you want to end up with a shape or path to create a shape? Seems like if it's the former and you want a Bezier curve, might just be worth it to bite down and trial-and-error till you're comfy with them; and if it's the latter, then working from an SVG is what you want? Unless I'm misinterpreting what you're proposing above? On Thu, Sep 19, 2024 at 5:29 PM Bob Carlson via Discuss < discuss@lists.openscad.org> wrote: > Is there a tool like this already out there? I played around a little with > InkScape, but didn’t see an easy way to use it. > > I keep facing the problem of creating a curve in OpenSCAD that matches the > one on a physical item. Bézier curves seems like a likely way to represent > the curve but I have never used them because it just seemed like a LOT of > trial and error was the only way. I have thought about what a tool would > look like and here is the outline of it. > > You have a 2D canvas, XY axes. You can import a JPG of the curve you need > to match. > > The JPG can be scaled up or down so that the physical measurements you > made of the object match the scale on the canvas. > > You can click on the canvas and create 1 or more Bézier curves on the > canvas and match them to the curve(s) on your JPG. Multiple curves could be > used for complex shapes. > > The curve parameters could then be copied and pasted into the OpenSCAD > code. Ideally it would even produce the code itself. > > It seems like this could be a tool built into the SCAD code, a kind of > Bezier sketchpad. > > Thoughts? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > -- - Jon Gilbert jong@jong.org / jgilbertsjc@gmail.com
GB
Glenn Butcher
Fri, Sep 20, 2024 1:08 AM

It's not quite what you're looking for, but I wrote a graphical tool to
let me plot points and collect them into an OpenSCAD point list:

https://github.com/butcherg/wxpolygon

Doesn't do Beziers or anything like that, but it does let you define a
third number for a point, a radius, to be used by the Round-Anything
polyRound() module which will replace a point with a radius with a set
of points outlining the radius.

https://github.com/Irev-Dev/Round-Anything

I think BOSL2 may also have such a tool.

On 9/19/2024 6:29 PM, Bob Carlson via Discuss wrote:

Is there a tool like this already out there? I played around a little with InkScape, but didn’t see an easy way to use it.

I keep facing the problem of creating a curve in OpenSCAD that matches the one on a physical item. Bézier curves seems like a likely way to represent the curve but I have never used them because it just seemed like a LOT of trial and error was the only way. I have thought about what a tool would look like and here is the outline of it.

You have a 2D canvas, XY axes. You can import a JPG of the curve you need to match.

The JPG can be scaled up or down so that the physical measurements you made of the object match the scale on the canvas.

You can click on the canvas and create 1 or more Bézier curves on the canvas and match them to the curve(s) on your JPG. Multiple curves could be used for complex shapes.

The curve parameters could then be copied and pasted into the OpenSCAD code. Ideally it would even produce the code itself.

It seems like this could be a tool built into the SCAD code, a kind of Bezier sketchpad.

Thoughts?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

It's not quite what you're looking for, but I wrote a graphical tool to let me plot points and collect them into an OpenSCAD point list: https://github.com/butcherg/wxpolygon Doesn't do Beziers or anything like that, but it does let you define a third number for a point, a radius, to be used by the Round-Anything polyRound() module which will replace a point with a radius with a set of points outlining the radius. https://github.com/Irev-Dev/Round-Anything I think BOSL2 may also have such a tool. On 9/19/2024 6:29 PM, Bob Carlson via Discuss wrote: > Is there a tool like this already out there? I played around a little with InkScape, but didn’t see an easy way to use it. > > I keep facing the problem of creating a curve in OpenSCAD that matches the one on a physical item. Bézier curves seems like a likely way to represent the curve but I have never used them because it just seemed like a LOT of trial and error was the only way. I have thought about what a tool would look like and here is the outline of it. > > You have a 2D canvas, XY axes. You can import a JPG of the curve you need to match. > > The JPG can be scaled up or down so that the physical measurements you made of the object match the scale on the canvas. > > You can click on the canvas and create 1 or more Bézier curves on the canvas and match them to the curve(s) on your JPG. Multiple curves could be used for complex shapes. > > The curve parameters could then be copied and pasted into the OpenSCAD code. Ideally it would even produce the code itself. > > It seems like this could be a tool built into the SCAD code, a kind of Bezier sketchpad. > > Thoughts? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
WF
William F. Adams
Fri, Sep 20, 2024 1:31 AM

Usually if they wish to work with something interactively folks just import the pixel image into a tool such as Inkscape, re-draw it, then make use of the SVG.

https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058

I'd love to see a simple OpenSCAD option, but solutions in this space always tend to multiply numbers and have quite complex interfaces, and the implementation goes even further down this road since one has to solve for the Bézier curve as a series of straight-line moves.

Some sort of native Bézier curve support would be ideal, and has been asked after/discussed here in the past, but doesn't seem to be on anyone's radar or compatible with the roadmap of the project as a whole (I'd love to be wrong).

William

--
Sphinx of black quartz, judge my vow.
https://designinto3d.com/

Usually if they wish to work with something interactively folks just import the pixel image into a tool such as Inkscape, re-draw it, then make use of the SVG. https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058 I'd love to see a simple OpenSCAD option, but solutions in this space always tend to multiply numbers and have quite complex interfaces, and the implementation goes even further down this road since one has to solve for the Bézier curve as a series of straight-line moves. Some sort of native Bézier curve support would be ideal, and has been asked after/discussed here in the past, but doesn't seem to be on anyone's radar or compatible with the roadmap of the project as a whole (I'd love to be wrong). William -- Sphinx of black quartz, judge my vow. https://designinto3d.com/
AM
Adrian Mariano
Fri, Sep 20, 2024 1:45 AM

Bezier curves have been implemented in various libraries, including BOSL2,
so if you can produce a bezier curve I'd say you've solved the problem.  I
don't think bezier curves are likely to ever appear in native OpenSCAD
because I got the impression that the developers see this as something
easily done in userspace.  I've started looking at a NURBS / B-spline
implementation, which I suspect will be easier to use for matching a
desired curve, but probably not ready for a while.

On Thu, Sep 19, 2024 at 9:32 PM William F. Adams via Discuss <
discuss@lists.openscad.org> wrote:

Usually if they wish to work with something interactively folks just
import the pixel image into a tool such as Inkscape, re-draw it, then make
use of the SVG.

https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058

I'd love to see a simple OpenSCAD option, but solutions in this space
always tend to multiply numbers and have quite complex interfaces, and the
implementation goes even further down this road since one has to solve for
the Bézier curve as a series of straight-line moves.

Some sort of native Bézier curve support would be ideal, and has been
asked after/discussed here in the past, but doesn't seem to be on anyone's
radar or compatible with the roadmap of the project as a whole (I'd love to
be wrong).

William

--
Sphinx of black quartz, judge my vow.
https://designinto3d.com/


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Bezier curves have been implemented in various libraries, including BOSL2, so if you can produce a bezier curve I'd say you've solved the problem. I don't think bezier curves are likely to ever appear in native OpenSCAD because I got the impression that the developers see this as something easily done in userspace. I've started looking at a NURBS / B-spline implementation, which I suspect will be easier to use for matching a desired curve, but probably not ready for a while. On Thu, Sep 19, 2024 at 9:32 PM William F. Adams via Discuss < discuss@lists.openscad.org> wrote: > Usually if they wish to work with something interactively folks just > import the pixel image into a tool such as Inkscape, re-draw it, then make > use of the SVG. > > > https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058 > > I'd love to see a simple OpenSCAD option, but solutions in this space > always tend to multiply numbers and have quite complex interfaces, and the > implementation goes even further down this road since one has to solve for > the Bézier curve as a series of straight-line moves. > > Some sort of native Bézier curve support would be ideal, and has been > asked after/discussed here in the past, but doesn't seem to be on anyone's > radar or compatible with the roadmap of the project as a whole (I'd love to > be wrong). > > William > > -- > Sphinx of black quartz, judge my vow. > https://designinto3d.com/ > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Fri, Sep 20, 2024 3:06 AM

What you describe is pretty much what I've done.  I bring the JPEG into
a tool like InkScape or CorelDraw, match the shapes with Bézier curves,
and then read out the control point coordinates and transcribe them into
my OpenSCAD program's calls to Bézier-generating functions.

The manual transcription is a bit of a pain, but not awful for modestly
complex shapes.

What you describe is pretty much what I've done.  I bring the JPEG into a tool like InkScape or CorelDraw, match the shapes with Bézier curves, and then read out the control point coordinates and transcribe them into my OpenSCAD program's calls to Bézier-generating functions. The manual transcription is a bit of a pain, but not awful for modestly complex shapes.
GS
Guenther Sohler
Fri, Sep 20, 2024 6:55 AM

Can you quickly send a link to an (trivial example of how to create a
NURBS/B-Splint example using
BOSL2 ?
Would it be an option that users use the OpenSCAD customizer to rectify
the correct  curved face ?

On Fri, Sep 20, 2024 at 3:45 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Bezier curves have been implemented in various libraries, including BOSL2,
so if you can produce a bezier curve I'd say you've solved the problem.  I
don't think bezier curves are likely to ever appear in native OpenSCAD
because I got the impression that the developers see this as something
easily done in userspace.  I've started looking at a NURBS / B-spline
implementation, which I suspect will be easier to use for matching a
desired curve, but probably not ready for a while.

On Thu, Sep 19, 2024 at 9:32 PM William F. Adams via Discuss <
discuss@lists.openscad.org> wrote:

Usually if they wish to work with something interactively folks just
import the pixel image into a tool such as Inkscape, re-draw it, then make
use of the SVG.

https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058

I'd love to see a simple OpenSCAD option, but solutions in this space
always tend to multiply numbers and have quite complex interfaces, and the
implementation goes even further down this road since one has to solve for
the Bézier curve as a series of straight-line moves.

Some sort of native Bézier curve support would be ideal, and has been
asked after/discussed here in the past, but doesn't seem to be on anyone's
radar or compatible with the roadmap of the project as a whole (I'd love to
be wrong).

William

--
Sphinx of black quartz, judge my vow.
https://designinto3d.com/


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Can you quickly send a link to an (trivial example of how to create a NURBS/B-Splint example using BOSL2 ? Would it be an option that users use the OpenSCAD customizer to rectify the correct curved face ? On Fri, Sep 20, 2024 at 3:45 AM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > Bezier curves have been implemented in various libraries, including BOSL2, > so if you can produce a bezier curve I'd say you've solved the problem. I > don't think bezier curves are likely to ever appear in native OpenSCAD > because I got the impression that the developers see this as something > easily done in userspace. I've started looking at a NURBS / B-spline > implementation, which I suspect will be easier to use for matching a > desired curve, but probably not ready for a while. > > On Thu, Sep 19, 2024 at 9:32 PM William F. Adams via Discuss < > discuss@lists.openscad.org> wrote: > >> Usually if they wish to work with something interactively folks just >> import the pixel image into a tool such as Inkscape, re-draw it, then make >> use of the SVG. >> >> >> https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058 >> >> I'd love to see a simple OpenSCAD option, but solutions in this space >> always tend to multiply numbers and have quite complex interfaces, and the >> implementation goes even further down this road since one has to solve for >> the Bézier curve as a series of straight-line moves. >> >> Some sort of native Bézier curve support would be ideal, and has been >> asked after/discussed here in the past, but doesn't seem to be on anyone's >> radar or compatible with the roadmap of the project as a whole (I'd love to >> be wrong). >> >> William >> >> -- >> Sphinx of black quartz, judge my vow. >> https://designinto3d.com/ >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RD
Revar Desmera
Fri, Sep 20, 2024 7:11 AM

While BOSL2 does have support for Bezier curves and surfaces, it does NOT have code to do B-Splines/NURBS.  About as close as it gets is the rather experimental code attached below.

  • Revar

On Sep 19, 2024, at 11:55 PM, Guenther Sohler via Discuss discuss@lists.openscad.org wrote:

Can you quickly send a link to an (trivial example of how to create a NURBS/B-Splint example using
BOSL2 ?
Would it be an option that users use the OpenSCAD customizer to rectify the correct  curved face ?

On Fri, Sep 20, 2024 at 3:45 AM Adrian Mariano via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Bezier curves have been implemented in various libraries, including BOSL2, so if you can produce a bezier curve I'd say you've solved the problem.  I don't think bezier curves are likely to ever appear in native OpenSCAD because I got the impression that the developers see this as something easily done in userspace.  I've started looking at a NURBS / B-spline implementation, which I suspect will be easier to use for matching a desired curve, but probably not ready for a while.

On Thu, Sep 19, 2024 at 9:32 PM William F. Adams via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Usually if they wish to work with something interactively folks just import the pixel image into a tool such as Inkscape, re-draw it, then make use of the SVG.

https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058

I'd love to see a simple OpenSCAD option, but solutions in this space always tend to multiply numbers and have quite complex interfaces, and the implementation goes even further down this road since one has to solve for the Bézier curve as a series of straight-line moves.

Some sort of native Bézier curve support would be ideal, and has been asked after/discussed here in the past, but doesn't seem to be on anyone's radar or compatible with the roadmap of the project as a whole (I'd love to be wrong).

William

--
Sphinx of black quartz, judge my vow.
https://designinto3d.com/


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

While BOSL2 does have support for Bezier curves and surfaces, it does NOT have code to do B-Splines/NURBS. About as close as it gets is the rather experimental code attached below. - Revar  > On Sep 19, 2024, at 11:55 PM, Guenther Sohler via Discuss <discuss@lists.openscad.org> wrote: > > Can you quickly send a link to an (trivial example of how to create a NURBS/B-Splint example using > BOSL2 ? > Would it be an option that users use the OpenSCAD customizer to rectify the correct curved face ? > > > > On Fri, Sep 20, 2024 at 3:45 AM Adrian Mariano via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >> Bezier curves have been implemented in various libraries, including BOSL2, so if you can produce a bezier curve I'd say you've solved the problem. I don't think bezier curves are likely to ever appear in native OpenSCAD because I got the impression that the developers see this as something easily done in userspace. I've started looking at a NURBS / B-spline implementation, which I suspect will be easier to use for matching a desired curve, but probably not ready for a while. >> >> On Thu, Sep 19, 2024 at 9:32 PM William F. Adams via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>> Usually if they wish to work with something interactively folks just import the pixel image into a tool such as Inkscape, re-draw it, then make use of the SVG. >>> >>> https://community.carbide3d.com/t/making-a-guitar-bridge-for-carbide-create-pro/70058 >>> >>> I'd love to see a simple OpenSCAD option, but solutions in this space always tend to multiply numbers and have quite complex interfaces, and the implementation goes even further down this road since one has to solve for the Bézier curve as a series of straight-line moves. >>> >>> Some sort of native Bézier curve support would be ideal, and has been asked after/discussed here in the past, but doesn't seem to be on anyone's radar or compatible with the roadmap of the project as a whole (I'd love to be wrong). >>> >>> William >>> >>> -- >>> Sphinx of black quartz, judge my vow. >>> https://designinto3d.com/ >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
SP
Sanjeev Prabhakar
Fri, Sep 20, 2024 7:18 AM

If you are trying to match an existing curve by taking points from the
existing curve then as per my understanding it is polynomial curve.

I don't think bezier can match than completely.
Maybe bspline if you have many points selected to match that curve.

To match a curve by picking few points especially where the curve is
changing direction, someone probably need to write polynomial curve.

It should be possible in openscad.

On Fri, 20 Sept, 2024, 5:59 am Bob Carlson via Discuss, <
discuss@lists.openscad.org> wrote:

Is there a tool like this already out there? I played around a little with
InkScape, but didn’t see an easy way to use it.

I keep facing the problem of creating a curve in OpenSCAD that matches the
one on a physical item. Bézier curves seems like a likely way to represent
the curve but I have never used them because it just seemed like a LOT of
trial and error was the only way. I have thought about what a tool would
look like and here is the outline of it.

You have a 2D canvas, XY axes. You can import a JPG of the curve you need
to match.

The JPG can be scaled up or down so that the physical measurements you
made of the object match the scale on the canvas.

You can click on the canvas and create 1 or more Bézier curves on the
canvas and match them to the curve(s) on your JPG. Multiple curves could be
used for complex shapes.

The curve parameters could then be copied and pasted into the OpenSCAD
code. Ideally it would even produce the code itself.

It seems like this could be a tool built into the SCAD code, a kind of
Bezier sketchpad.

Thoughts?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

If you are trying to match an existing curve by taking points from the existing curve then as per my understanding it is polynomial curve. I don't think bezier can match than completely. Maybe bspline if you have many points selected to match that curve. To match a curve by picking few points especially where the curve is changing direction, someone probably need to write polynomial curve. It should be possible in openscad. On Fri, 20 Sept, 2024, 5:59 am Bob Carlson via Discuss, < discuss@lists.openscad.org> wrote: > Is there a tool like this already out there? I played around a little with > InkScape, but didn’t see an easy way to use it. > > I keep facing the problem of creating a curve in OpenSCAD that matches the > one on a physical item. Bézier curves seems like a likely way to represent > the curve but I have never used them because it just seemed like a LOT of > trial and error was the only way. I have thought about what a tool would > look like and here is the outline of it. > > You have a 2D canvas, XY axes. You can import a JPG of the curve you need > to match. > > The JPG can be scaled up or down so that the physical measurements you > made of the object match the scale on the canvas. > > You can click on the canvas and create 1 or more Bézier curves on the > canvas and match them to the curve(s) on your JPG. Multiple curves could be > used for complex shapes. > > The curve parameters could then be copied and pasted into the OpenSCAD > code. Ideally it would even produce the code itself. > > It seems like this could be a tool built into the SCAD code, a kind of > Bezier sketchpad. > > Thoughts? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
CM
Curt McDowell
Fri, Sep 20, 2024 7:46 AM

On 9/19/2024 5:29 PM, Bob Carlson via Discuss wrote:

Is there a tool like this already out there? I played around a little with InkScape, but didn’t see an easy way to use it.

I keep facing the problem of creating a curve in OpenSCAD that matches the one on a physical item. Bézier curves seems like a likely way to represent the curve but I have never used them because it just seemed like a LOT of trial and error was the only way. I have thought about what a tool would look like and here is the outline of it.

Funny you mention it now because I just spent many hours solving a
problem like that. All the while, I was wondering what kind of
functionality OpenSCAD might be able to integrate for this purpose.

I needed to replicate a bracket made out of thin acrylic.

I traced it on paper and annotated it with caliper measurements:

I opened Inkscape and decided it was too much to learn just then. I
remembered playing with SolveSpace before, the parametric solver, so I
opened that instead. It turned out to be easy to import an background
image and draw over it. Though it took me a while to figure out what to
do, but my final process was:

  • Draw a closed curve comprising connected lines and arcs in the
    approximate shape (or just one half, because of symmetry).
  • Apply constraints for tangency and parallelism. It actually gets
    pretty easy after playing around for a while. It's not necessary to
    fully constrain every single thing.
  • Drag points around until it matches the picture.
  • Extrude vertically and export as an STL mesh.

I wrote an OpenSCAD script to import the STL, scale it to actual size,
mirror the right half, punch holes, etc. Some of that was a bit tricky
because I had to create cutter cylinders and cubes and translate them to
the correct angles and positions by trial and error.

module bracket_half() {
     difference() {
         // The 0.973 makes the far side of the two pins 48.4 wide
         scale([63.2 / 2 / 8.196650 * 0.973, 97 / 23.864340, 4.5 /
8.972530])
             import("bracket.stl", convexity = 2);
         // Chop off some of the inside of the pins so the inside
distance is 19.6
         translate([-9.8, -44.4, -1])
             cube([9.8, 15.17, 5]);
         // Chop off wedges to make the pins trapezoidal
         translate([-7.47, -44.25, -5])
             rotate([0, -25, 0])
                 cube([15, 15, 15]);
         translate([-26.54, -44.25, -5])
             rotate([0, -65, 0])
                 cube([15, 15, 15]);
     }
}

module bracket()
     difference() {
         union() {
             bracket_half();
             mirror([1, 0, 0])
                 bracket_half();
         }
         // Bottom hole
         translate([0, 30.5, -1])
            cylinder(d = 8, h = 10, $fn = 60);
         // Top hole
         translate([0, 45.1, -1])
            cylinder(d = 8, h = 10, $fn = 60);
         // Round off the top divot
         translate([0, 57.31, -1])
             scale([9.5, 1, 1])
                 cylinder(d = 1, h = 7, $fn = 60);
         // Take 2mm off the pins
         translate([0, -48, -5])
             cube([100, 20, 20], center = true);
     }

//bracket_half();
bracket();

I was then able to print two in Overture Transparent PETG. I followed
some "printing glass" instructions from the Web, but this'll have to do.
It was done for a friend, mostly for fun, and the amount of time
required (at my pre-retirement pay grade) would have cost something
upwards of $1000 (kind of ridiculous :).

Besides drawing 2D curves, SolveSpace does complicated 3D objects.
Wouldn't it be nice if you could write parametric statements in OpenSCAD
like "make a sphere tangent to this face of this cube and passing
through this point on this other cube"? Referencing previously defined
objects might be a lot easier in Python SCAD.

Regards,
Curt

On 9/19/2024 5:29 PM, Bob Carlson via Discuss wrote: > Is there a tool like this already out there? I played around a little with InkScape, but didn’t see an easy way to use it. > > I keep facing the problem of creating a curve in OpenSCAD that matches the one on a physical item. Bézier curves seems like a likely way to represent the curve but I have never used them because it just seemed like a LOT of trial and error was the only way. I have thought about what a tool would look like and here is the outline of it. Funny you mention it now because I just spent many hours solving a problem like that. All the while, I was wondering what kind of functionality OpenSCAD might be able to integrate for this purpose. I needed to replicate a bracket made out of thin acrylic. I traced it on paper and annotated it with caliper measurements: I opened Inkscape and decided it was too much to learn just then. I remembered playing with SolveSpace before, the parametric solver, so I opened that instead. It turned out to be easy to import an background image and draw over it. Though it took me a while to figure out what to do, but my final process was: - Draw a closed curve comprising connected lines and arcs in the approximate shape (or just one half, because of symmetry). - Apply constraints for tangency and parallelism. It actually gets pretty easy after playing around for a while. It's not necessary to fully constrain every single thing. - Drag points around until it matches the picture. - Extrude vertically and export as an STL mesh. I wrote an OpenSCAD script to import the STL, scale it to actual size, mirror the right half, punch holes, etc. Some of that was a bit tricky because I had to create cutter cylinders and cubes and translate them to the correct angles and positions by trial and error. module bracket_half() {     difference() {         // The 0.973 makes the far side of the two pins 48.4 wide         scale([63.2 / 2 / 8.196650 * 0.973, 97 / 23.864340, 4.5 / 8.972530])             import("bracket.stl", convexity = 2);         // Chop off some of the inside of the pins so the inside distance is 19.6         translate([-9.8, -44.4, -1])             cube([9.8, 15.17, 5]);         // Chop off wedges to make the pins trapezoidal         translate([-7.47, -44.25, -5])             rotate([0, -25, 0])                 cube([15, 15, 15]);         translate([-26.54, -44.25, -5])             rotate([0, -65, 0])                 cube([15, 15, 15]);     } } module bracket()     difference() {         union() {             bracket_half();             mirror([1, 0, 0])                 bracket_half();         }         // Bottom hole         translate([0, 30.5, -1])            cylinder(d = 8, h = 10, $fn = 60);         // Top hole         translate([0, 45.1, -1])            cylinder(d = 8, h = 10, $fn = 60);         // Round off the top divot         translate([0, 57.31, -1])             scale([9.5, 1, 1])                 cylinder(d = 1, h = 7, $fn = 60);         // Take 2mm off the pins         translate([0, -48, -5])             cube([100, 20, 20], center = true);     } //bracket_half(); bracket(); I was then able to print two in Overture Transparent PETG. I followed some "printing glass" instructions from the Web, but this'll have to do. It was done for a friend, mostly for fun, and the amount of time required (at my pre-retirement pay grade) would have cost something upwards of $1000 (kind of ridiculous :). Besides drawing 2D curves, SolveSpace does complicated 3D objects. Wouldn't it be nice if you could write parametric statements in OpenSCAD like "make a sphere tangent to this face of this cube and passing through this point on this other cube"? Referencing previously defined objects might be a lot easier in Python SCAD. Regards, Curt