discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Finding the widest part of an imported svg

RV
Roel Vanhout
Tue, Apr 6, 2021 9:00 AM

Hi,

Up until today I have usually found ways to do what I want with OpenSCAD,
but now I have an idea with more 'organic' inputs and I'm stumped.

Basically, I want to make a 3d-printable knife sheath. The idea is that you
provide an svg with the outline of the knife (easily made by photographing
the knife with a reference distance drawn on some paper and then scaling
and tracing the knife outline in Inkscape), and then my OpenSCAD model
derives a suitable sheath from that svg. But when you have a knife that is
wider in the middle than at the sides (i.e. knife has a bit of a 'belly'),
then the 'entrance' of the sheath has to be as wide as the widest part of
the knife, of course. (see https://imgur.com/a/YuG3eWi for a crude sketch
of what I mean). Basically what I'm looking for is a way to find the widest
part of a path that was imported with import() and then 'project' that to
the side of my model (i.e., in the linked image, find the x-location of the
widest part, indicated with the red line, and then project it to the
right). The 'projection' part I can do by drawing a box but I need to know
where to set its origin, i.e. the x-location of the red line.

I'm ok with some constraints, like assuming that the spine (top) of the
knife is perfectly horizontal in the source svg, and that the tang (handle)
is always at the right, so that the 'projection' is basically always along
the positive x-axis.

Or maybe I'm barking up the wrong tree completely with my approach and
there is a better way; I'm open to such a different approach too, of course.

Thanks.

cheers

Roel

Hi, Up until today I have usually found ways to do what I want with OpenSCAD, but now I have an idea with more 'organic' inputs and I'm stumped. Basically, I want to make a 3d-printable knife sheath. The idea is that you provide an svg with the outline of the knife (easily made by photographing the knife with a reference distance drawn on some paper and then scaling and tracing the knife outline in Inkscape), and then my OpenSCAD model derives a suitable sheath from that svg. But when you have a knife that is wider in the middle than at the sides (i.e. knife has a bit of a 'belly'), then the 'entrance' of the sheath has to be as wide as the widest part of the knife, of course. (see https://imgur.com/a/YuG3eWi for a crude sketch of what I mean). Basically what I'm looking for is a way to find the widest part of a path that was imported with import() and then 'project' that to the side of my model (i.e., in the linked image, find the x-location of the widest part, indicated with the red line, and then project it to the right). The 'projection' part I can do by drawing a box but I need to know where to set its origin, i.e. the x-location of the red line. I'm ok with some constraints, like assuming that the spine (top) of the knife is perfectly horizontal in the source svg, and that the tang (handle) is always at the right, so that the 'projection' is basically always along the positive x-axis. Or maybe I'm barking up the wrong tree completely with my approach and there is a better way; I'm open to such a different approach too, of course. Thanks. cheers Roel
L
lar3ry
Tue, Apr 6, 2021 3:46 PM

I would use Inkscape to massage the 2D outline before bringing it in to
OpenSCAD.

Two ways to go about this.
You can trace, then remove the bitmap, remove either the inner or outer line
(a trace of a line gives you two lines bracketing the drawn line). Then you
can use the node editor tool to manipulate the shape, adding. removing, and
moving nodes, as well as smoothing them with the bezier handles.

Or you could just load the bitmap, make a new layer, lock the bitmap layer,
and draw your outline with the bezier line tool, following the line on the
bitmap.

Depending on complexity, one of these is usually easier. For this job, I
would use the second choice.

Roel Vanhout wrote

Hi,

Up until today I have usually found ways to do what I want with OpenSCAD,
but now I have an idea with more 'organic' inputs and I'm stumped.

Basically, I want to make a 3d-printable knife sheath. The idea is that
you
provide an svg with the outline of the knife (easily made by photographing
the knife with a reference distance drawn on some paper and then scaling
and tracing the knife outline in Inkscape), and then my OpenSCAD model
derives a suitable sheath from that svg. But when you have a knife that is
wider in the middle than at the sides (i.e. knife has a bit of a 'belly'),
then the 'entrance' of the sheath has to be as wide as the widest part of
the knife, of course. (see https://imgur.com/a/YuG3eWi for a crude sketch
of what I mean). Basically what I'm looking for is a way to find the
widest
part of a path that was imported with import() and then 'project' that to
the side of my model (i.e., in the linked image, find the x-location of
the
widest part, indicated with the red line, and then project it to the
right). The 'projection' part I can do by drawing a box but I need to know
where to set its origin, i.e. the x-location of the red line.

I'm ok with some constraints, like assuming that the spine (top) of the
knife is perfectly horizontal in the source svg, and that the tang
(handle)
is always at the right, so that the 'projection' is basically always along
the positive x-axis.

Or maybe I'm barking up the wrong tree completely with my approach and
there is a better way; I'm open to such a different approach too, of
course.

Thanks.

cheers

Roel


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad

I would use Inkscape to massage the 2D outline before bringing it in to OpenSCAD. Two ways to go about this. You can trace, then remove the bitmap, remove either the inner or outer line (a trace of a line gives you two lines bracketing the drawn line). Then you can use the node editor tool to manipulate the shape, adding. removing, and moving nodes, as well as smoothing them with the bezier handles. Or you could just load the bitmap, make a new layer, lock the bitmap layer, and draw your outline with the bezier line tool, following the line on the bitmap. Depending on complexity, one of these is usually easier. For this job, I would use the second choice. Roel Vanhout wrote > Hi, > > Up until today I have usually found ways to do what I want with OpenSCAD, > but now I have an idea with more 'organic' inputs and I'm stumped. > > Basically, I want to make a 3d-printable knife sheath. The idea is that > you > provide an svg with the outline of the knife (easily made by photographing > the knife with a reference distance drawn on some paper and then scaling > and tracing the knife outline in Inkscape), and then my OpenSCAD model > derives a suitable sheath from that svg. But when you have a knife that is > wider in the middle than at the sides (i.e. knife has a bit of a 'belly'), > then the 'entrance' of the sheath has to be as wide as the widest part of > the knife, of course. (see https://imgur.com/a/YuG3eWi for a crude sketch > of what I mean). Basically what I'm looking for is a way to find the > widest > part of a path that was imported with import() and then 'project' that to > the side of my model (i.e., in the linked image, find the x-location of > the > widest part, indicated with the red line, and then project it to the > right). The 'projection' part I can do by drawing a box but I need to know > where to set its origin, i.e. the x-location of the red line. > > I'm ok with some constraints, like assuming that the spine (top) of the > knife is perfectly horizontal in the source svg, and that the tang > (handle) > is always at the right, so that the 'projection' is basically always along > the positive x-axis. > > Or maybe I'm barking up the wrong tree completely with my approach and > there is a better way; I'm open to such a different approach too, of > course. > > Thanks. > > cheers > > Roel > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to > discuss-leave@.openscad -- Sent from: http://forum.openscad.org/
FV
Frank van der Hulst
Wed, Apr 7, 2021 4:48 AM

Try drawing circles inside the knife outline, tangential to the edges? The
diameter of the largest circle defines the minimum sheath opening width, I
think? Possibly doing a hull() beforehand over the knife might be useful?

There are probably some cases where the circles won't work (e.g. zig-zag
edges opposite each other or spirals), but I'm guessing they're probably
not all that relevant to knife design.

On Tue, Apr 6, 2021 at 9:01 PM Roel Vanhout roel.vanhout@gmail.com wrote:

Hi,

Up until today I have usually found ways to do what I want with OpenSCAD,
but now I have an idea with more 'organic' inputs and I'm stumped.

Basically, I want to make a 3d-printable knife sheath. The idea is that
you provide an svg with the outline of the knife (easily made by
photographing the knife with a reference distance drawn on some paper and
then scaling and tracing the knife outline in Inkscape), and then my
OpenSCAD model derives a suitable sheath from that svg. But when you have a
knife that is wider in the middle than at the sides (i.e. knife has a bit
of a 'belly'), then the 'entrance' of the sheath has to be as wide as the
widest part of the knife, of course. (see https://imgur.com/a/YuG3eWi for
a crude sketch of what I mean). Basically what I'm looking for is a way to
find the widest part of a path that was imported with import() and then
'project' that to the side of my model (i.e., in the linked image, find the
x-location of the widest part, indicated with the red line, and then
project it to the right). The 'projection' part I can do by drawing a box
but I need to know where to set its origin, i.e. the x-location of the red
line.

I'm ok with some constraints, like assuming that the spine (top) of the
knife is perfectly horizontal in the source svg, and that the tang (handle)
is always at the right, so that the 'projection' is basically always along
the positive x-axis.

Or maybe I'm barking up the wrong tree completely with my approach and
there is a better way; I'm open to such a different approach too, of course.

Thanks.

cheers

Roel


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

Try drawing circles inside the knife outline, tangential to the edges? The diameter of the largest circle defines the minimum sheath opening width, I think? Possibly doing a hull() beforehand over the knife might be useful? There are probably some cases where the circles won't work (e.g. zig-zag edges opposite each other or spirals), but I'm guessing they're probably not all that relevant to knife design. On Tue, Apr 6, 2021 at 9:01 PM Roel Vanhout <roel.vanhout@gmail.com> wrote: > Hi, > > Up until today I have usually found ways to do what I want with OpenSCAD, > but now I have an idea with more 'organic' inputs and I'm stumped. > > Basically, I want to make a 3d-printable knife sheath. The idea is that > you provide an svg with the outline of the knife (easily made by > photographing the knife with a reference distance drawn on some paper and > then scaling and tracing the knife outline in Inkscape), and then my > OpenSCAD model derives a suitable sheath from that svg. But when you have a > knife that is wider in the middle than at the sides (i.e. knife has a bit > of a 'belly'), then the 'entrance' of the sheath has to be as wide as the > widest part of the knife, of course. (see https://imgur.com/a/YuG3eWi for > a crude sketch of what I mean). Basically what I'm looking for is a way to > find the widest part of a path that was imported with import() and then > 'project' that to the side of my model (i.e., in the linked image, find the > x-location of the widest part, indicated with the red line, and then > project it to the right). The 'projection' part I can do by drawing a box > but I need to know where to set its origin, i.e. the x-location of the red > line. > > I'm ok with some constraints, like assuming that the spine (top) of the > knife is perfectly horizontal in the source svg, and that the tang (handle) > is always at the right, so that the 'projection' is basically always along > the positive x-axis. > > Or maybe I'm barking up the wrong tree completely with my approach and > there is a better way; I'm open to such a different approach too, of course. > > Thanks. > > cheers > > Roel > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
M
MichaelAtOz
Wed, Apr 7, 2021 4:58 AM

This may help https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Computing_a_bounding_box


From: Roel Vanhout [mailto:roel.vanhout@gmail.com]
Sent: Tue, 6 Apr 2021 19:01
To: OpenSCAD general discussion
Subject: [OpenSCAD] Finding the widest part of an imported svg

Hi,

Up until today I have usually found ways to do what I want with OpenSCAD, but now I have an idea with more 'organic' inputs and I'm stumped.

Basically, I want to make a 3d-printable knife sheath. The idea is that you provide an svg with the outline of the knife (easily made by photographing the knife with a reference distance drawn on some paper and then scaling and tracing the knife outline in Inkscape), and then my OpenSCAD model derives a suitable sheath from that svg. But when you have a knife that is wider in the middle than at the sides (i.e. knife has a bit of a 'belly'), then the 'entrance' of the sheath has to be as wide as the widest part of the knife, of course. (see https://imgur.com/a/YuG3eWi for a crude sketch of what I mean). Basically what I'm looking for is a way to find the widest part of a path that was imported with import() and then 'project' that to the side of my model (i.e., in the linked image, find the x-location of the widest part, indicated with the red line, and then project it to the right). The 'projection' part I can do by drawing a box but I need to know where to set its origin, i.e. the x-location of the red line.

I'm ok with some constraints, like assuming that the spine (top) of the knife is perfectly horizontal in the source svg, and that the tang (handle) is always at the right, so that the 'projection' is basically always along the positive x-axis.

Or maybe I'm barking up the wrong tree completely with my approach and there is a better way; I'm open to such a different approach too, of course.

Thanks.

cheers

Roel

--
This email has been checked for viruses by AVG.
https://www.avg.com

This may help https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Computing_a_bounding_box _____ From: Roel Vanhout [mailto:roel.vanhout@gmail.com] Sent: Tue, 6 Apr 2021 19:01 To: OpenSCAD general discussion Subject: [OpenSCAD] Finding the widest part of an imported svg Hi, Up until today I have usually found ways to do what I want with OpenSCAD, but now I have an idea with more 'organic' inputs and I'm stumped. Basically, I want to make a 3d-printable knife sheath. The idea is that you provide an svg with the outline of the knife (easily made by photographing the knife with a reference distance drawn on some paper and then scaling and tracing the knife outline in Inkscape), and then my OpenSCAD model derives a suitable sheath from that svg. But when you have a knife that is wider in the middle than at the sides (i.e. knife has a bit of a 'belly'), then the 'entrance' of the sheath has to be as wide as the widest part of the knife, of course. (see https://imgur.com/a/YuG3eWi for a crude sketch of what I mean). Basically what I'm looking for is a way to find the widest part of a path that was imported with import() and then 'project' that to the side of my model (i.e., in the linked image, find the x-location of the widest part, indicated with the red line, and then project it to the right). The 'projection' part I can do by drawing a box but I need to know where to set its origin, i.e. the x-location of the red line. I'm ok with some constraints, like assuming that the spine (top) of the knife is perfectly horizontal in the source svg, and that the tang (handle) is always at the right, so that the 'projection' is basically always along the positive x-axis. Or maybe I'm barking up the wrong tree completely with my approach and there is a better way; I'm open to such a different approach too, of course. Thanks. cheers Roel -- This email has been checked for viruses by AVG. https://www.avg.com
T
TLC123
Wed, Apr 7, 2021 12:23 PM
-- Sent from: http://forum.openscad.org/
NH
nop head
Wed, Apr 7, 2021 12:57 PM

You can't find it numerically but you can project it along its length to
get a rectangle the same width as the widest point. In fact, you can do
that three times to create a bonding cube for any 3D object.

There is also an InkScape extension that outputs an OpenSCAD polygon and
you can then find the min and max values in that list of points.

On Wed, 7 Apr 2021 at 13:23, TLC123 torleif.ceder@gmail.com wrote:

blade_thickness=3;
epsilon=1e-20;
blade();
translate([0,50])sheath();

module sheath() {

 hull(){
 blade();
  linear_extrude(epsilon) projection()blade() ;

}
}

module blade()
{rotate([0,-90])
linear_extrude(blade_thickness, center=true)
blade_profile();

 }

module blade_profile(){
//import your svg
polygon([[0,0],[30,-5],[70,-20],[130,-15],[200,10],[130,7],[100,10],[0,10]]);

 }

Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


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

You can't find it numerically but you can project it along its length to get a rectangle the same width as the widest point. In fact, you can do that three times to create a bonding cube for any 3D object. There is also an InkScape extension that outputs an OpenSCAD polygon and you can then find the min and max values in that list of points. On Wed, 7 Apr 2021 at 13:23, TLC123 <torleif.ceder@gmail.com> wrote: > blade_thickness=3; > epsilon=1e-20; > blade(); > translate([0,50])sheath(); > > > module sheath() { > > hull(){ > blade(); > linear_extrude(epsilon) projection()blade() ; > } > } > > > > module blade() > {rotate([0,-90]) > linear_extrude(blade_thickness, center=true) > blade_profile(); > > } > module blade_profile(){ > //import your svg > polygon([[0,0],[30,-5],[70,-20],[130,-15],[200,10],[130,7],[100,10],[0,10]]); > > } > > > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RV
Roel Vanhout
Thu, Apr 8, 2021 9:42 AM

Thanks all (also to the person who privately mailed me code with a similar
solution), the right combinations of projection() and hull() did it.

cheers

On Wed, Apr 7, 2021 at 2:23 PM TLC123 torleif.ceder@gmail.com wrote:

blade_thickness=3;
epsilon=1e-20;
blade();
translate([0,50])sheath();

module sheath() {

 hull(){
 blade();
  linear_extrude(epsilon) projection()blade() ;

}
}

module blade()
{rotate([0,-90])
linear_extrude(blade_thickness, center=true)
blade_profile();

 }

module blade_profile(){
//import your svg
polygon([[0,0],[30,-5],[70,-20],[130,-15],[200,10],[130,7],[100,10],[0,10]]);

 }

Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


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

Thanks all (also to the person who privately mailed me code with a similar solution), the right combinations of projection() and hull() did it. cheers On Wed, Apr 7, 2021 at 2:23 PM TLC123 <torleif.ceder@gmail.com> wrote: > blade_thickness=3; > epsilon=1e-20; > blade(); > translate([0,50])sheath(); > > > module sheath() { > > hull(){ > blade(); > linear_extrude(epsilon) projection()blade() ; > } > } > > > > module blade() > {rotate([0,-90]) > linear_extrude(blade_thickness, center=true) > blade_profile(); > > } > module blade_profile(){ > //import your svg > polygon([[0,0],[30,-5],[70,-20],[130,-15],[200,10],[130,7],[100,10],[0,10]]); > > } > > > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >