Nabble removed Mailing-list integration from the Forum.
This killed the Forum. This is now an ARCHIVE.
It is likely Nabble will shutdown in the future.

So basically the Forum is now out of date, we are looking into migrating the history.

OpenSCAD support is now provided by the Mailing List.
See the first pinned post here for instructions on subscribing to the mailing list.

Finding the widest part of an imported svg

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

Finding the widest part of an imported svg

Roel Vanhout
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 [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Finding the widest part of an imported svg

lar3ry
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 [hidden email]


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Finding the widest part of an imported svg

frankv
In reply to this post by Roel Vanhout
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 <[hidden email]> 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 [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Finding the widest part of an imported svg

MichaelAtOz
Administrator
In reply to this post by Roel Vanhout

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

 


From: Roel Vanhout [mailto:[hidden email]]
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

 


Virus-free. www.avg.com

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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

Re: Finding the widest part of an imported svg

TLC123
In reply to this post by Roel Vanhout
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 at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Finding the widest part of an imported svg

nophead
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Finding the widest part of an imported svg

Roel Vanhout
In reply to this post by TLC123
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]