Author Topic: Sloped Surface Following Polyline  (Read 22372 times)

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Sloped Surface Following Polyline
« on: October 07, 2015, 09:33:35 am »
This is a first cut, only slightly tested, of a script I intend to use to help cut simple contours on electric guitar/bass bodies without resorting to external tools, alternate file formats, and 3D surfaces all the time.  My goal is to produce a whole instrument using only CamBam.  :-\

This is based on ideas in 10bulls' Sloped Lines script as well as EddyCurrent's Text on Polyline among others.

Fair warning: I use the term "scan lines" a lot here because part of this effort reminded me of interlaced video scan lines.  What's a better term?  Cut lines?

To Use:

Select 2 or 3 open polylines in order of:

1) curve you want the slope to follow
2) single segment "vector" polyline defining the direction and length of the slope you want to build
3) OPTIONAL bounding curve where you want the slope to end

Set "Behavior" to one of:

ConstantAngle - sloped surface will have a constant angle but may have variable Z at the scan line endpoints if a boundary curve is selected
ConstantHeight - sloped surface will have a constant Z at the end of each scan line but the slope angle may actually too extreme to cut if a boundary curve is too close to the curve being followed

set "Orientation" to one of:

Parallel - orient generated scan lines parallel to the vector
Perpendicular - orient generated scan lines perpendicular to the curve being followed

Like the sloped lines script this is based on, the machine operation should be an engrave operation with 0 depth and optimization set to none.

When the slope of the vector polyline is negative (second point is lower in Z than the first point) the scan lines are generated FROM the curve being followed.  If the vector has a positive slope the direction is reversed and the scan lines are generated TO MEET the curve being followed.  This should be useful for cutting FROM a convex curve when the scan lines would spread out beyond the selected step over or even the bit diameter

The script attempts to compensate for bit diameter and does some rudimentary roughing optimization by skipping every other scan line except on the final pass. (this is the interlacing part)

I used an earlier version of the script to cut the belly contour (http://www.cambam.co.uk/forum/index.php?action=dlattach;topic=5153.0;attach=13887) on a micro-bass project I've been prototyping for the last month or so. 

I'll be cutting another prototype of the micro-bass this weekend and will use the script on both the arm bevel and belly contour but I wanted to get some feedback on suggestions or possible pitfalls.

Attached is a test CB file and a few pics of the generated scan lines.

D

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #1 on: October 07, 2015, 14:16:10 pm »
It's a marvelous script allright  ;D

I made a layer for each of the scanline rows, this made it easy to right click and 'select all on layer'
Then applied an engraving MOP to each layer as you specified and using a 1/2" ball nose cutter.
The results in CutViwerMill as per attached picture.

Edit: And then I found one engraving MOP worked if all the polylines were in one layer and in the correct cut order  :D
       So in fact the original countour.cb file of the OP's was fine once I added the engraving MOP, I only tried the Layer named, 1+2+3 Constant Angle Perpendicular
« Last Edit: October 07, 2015, 14:40:08 pm by EddyCurrent »
Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Sloped Surface Following Polyline
« Reply #2 on: October 07, 2015, 16:40:56 pm »
Hello,

welcome on the forum ... and in the "mad coders" area ! ;D

++
David

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #3 on: October 07, 2015, 17:22:40 pm »
It's a marvelous script allright  ;D

I made a layer for each of the scanline rows, this made it easy to right click and 'select all on layer'
Then applied an engraving MOP to each layer as you specified and using a 1/2" ball nose cutter.
The results in CutViwerMill as per attached picture.

Edit: And then I found one engraving MOP worked if all the polylines were in one layer and in the correct cut order  :D
       So in fact the original countour.cb file of the OP's was fine once I added the engraving MOP, I only tried the Layer named, 1+2+3 Constant Angle Perpendicular


Thanks Eddy!  Yeah, the inspiration script worked similarly.  I had a fun time with the boundary curve concept.  Originally I tried a trim operation but I found CB breaks polylines into (I guess) "manageable segments" when it's doing that so I wasn't sure if I could trust the engrave MOP with no optimization to behave the same way.

Just be careful when/if you select ConstantHeight as the behavior with a boundary curve...  those slopes can get pretty steep if the boundary is real close to the followed curve and so you could end up plunging faster than you might want to.  I haven't used it yet but I keep teasing my son I'm going to make him a micro-bass sized Gene Simmons axe bass (we call it the hatchet bass) and I think I'll need that sort of slope for the blade.

D

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #4 on: October 07, 2015, 17:32:09 pm »
Hello,

welcome on the forum ... and in the "mad coders" area ! ;D

++
David

Ha!  Thanks David!  yup..  that's me.. mad C/Unix coder for 30 years in anything from weapon systems simulation to telecommunications to healthcare.  This stuff is fun but since I'm a procedural code dinosaur (no C# in my history) and not much on VBScript and not real familiar with CB objects and methods I'm doing the best I can (so far).  I have a feeling I may be doing some things about as inefficiently as possible but I'm going to fall back on "I don't know any better (yet)".

Now, for my next trick...  I need a script/plugin/process that will break a closed polyline (in the shape of a guitar/bass body) into pieces at the inflection points of the curve.  Any ideas?

Dan

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Sloped Surface Following Polyline
« Reply #5 on: October 07, 2015, 17:41:31 pm »
Re

Quote
I'm a procedural code dinosaur (no C# in my history)

me too, I'm discovering "object programming" ..

Quote
I need a script/plugin/process that will break a closed polyline (in the shape of a guitar/bass body) into pieces at the inflection points of the curve.  Any ideas?

Ouch !! .. to much math for me  ;D

https://en.wikipedia.org/wiki/Inflection_point

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #6 on: October 07, 2015, 18:54:23 pm »
Dan,

You will soon get a grip on C#, most of us were in the same boat as you, e.g. ANSI C etc. in DOS.


Now, for my next trick...  I need a script/plugin/process that will break a closed polyline (in the shape of a guitar/bass body) into pieces at the inflection points of the curve.  Any ideas?

Dan

By way of example I just used the polyline in your first post, it's manual but works well.
If you draw two small polylines across where you want the break then select all 3 polylines, right click, Edit -> Break at Intersections.


Filmed in Supermarionation

Online dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7408
    • View Profile
    • Cambam V1.0 French Doc
Re: Sloped Surface Following Polyline
« Reply #7 on: October 07, 2015, 20:24:45 pm »
Hello,

Quote
If you draw two small polylines across where you want the break then select all 3 polylines, right click, Edit -> Break at Intersections.

Ah ! I misunderstood the question, I understood that the pb is to find where the curve direction change .. oops

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #8 on: October 07, 2015, 21:12:01 pm »
David,

No, you may well be correct, my method was just to make it easy  :D
Having looked at a Jackson guitar I can see that the large belly cut starts and ends at the peaks ( turning  points ) of the upper bout and upper horn curves.
Some other guitars however have slightly smaller belly cuts that do not extend to the turning points.

And now I'm wondering if Dan means 'turning points' or maybe he has plans for something else ?
« Last Edit: October 07, 2015, 21:17:45 pm by EddyCurrent »
Filmed in Supermarionation

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #9 on: October 08, 2015, 09:01:02 am »
Hello,

Quote
If you draw two small polylines across where you want the break then select all 3 polylines, right click, Edit -> Break at Intersections.

Ah ! I misunderstood the question, I understood that the pb is to find where the curve direction change .. oops

++
David

No David, You got it right.  I meant the places where the curvature on a shape changes from concave to convex since I would use the sloped surface script differently between the two situations.  The scan lines would diverge at the end points when following a convex curve, possibly further than the diameter of the router bit.

Anyway, ordinarily you use calculus when you have a well behaved function to work with but you can't really take the second derivative of a drawing...

 :)

The cool thing is the math world worked very well for a LONG time before Newton and Leibniz invented calculus.  Finding inflection points in CamBam wasn't really difficult so much as it was tedious.  Here's a pic of what I finally got...  the polyline isn't duplicated into its own layer and broken at the points yet and the code is pretty ugly so I'm not going to post it yet but this illustration should give you guys an idea of what I mean to get out of it.

I know the shape here is a jazz bass type body but if you've ever seen a Traben bass (my son's current brand) you'd see the entire body has a sort of variable chamfer all around it on the top plus a few scoops here and there on the back.  I'm not saying I want to make a copy of a Traben but if he gets the idea that he wants something similar I should be able to accommodate it.

D

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #10 on: October 08, 2015, 11:16:39 am »
Dan, Nice job. I was thinking you must have something else in mind other then the belly cut and arm rest otherwise the inflection points would not make full sense.

I'm guessing you stepped around the polyline segments until the bulge changed sign ?

You have to make the jump to writing Plugins though.
« Last Edit: October 08, 2015, 11:37:27 am by EddyCurrent »
Filmed in Supermarionation

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #11 on: October 08, 2015, 16:29:04 pm »
I'm guessing you stepped around the polyline segments until the bulge changed sign ?

Well, actually...  I re-segmented the polyline to my desired stepover width and then calculated the azimuth of each segment and then computed the difference in the azimuths for two adjacent segments and then stored the sign of that difference to determine the general trend in the curvature but when the difference is zero (i.e. two adjacent segments point in the same direction) I stepped backward through the list of segments to assign the next direction after the zero and then I stepped forward again through the segments and when I found a direction change I looked ahead 4 or 5 segments to make sure the direction change wasn't just a one off anomaly...

So you're right, I stepped around the curve until the direction trend changed sign...  just in known step widths.

Oh yeah and I mentioned I once did weapon systems simulation so my old brain found it easier to use normalized coordinates in degrees from north to +/- 180 degrees south instead of radians from positive X axis.  That'll have to change.

The method is pretty brute-force for sure but it seems stable.  You mean there's probably an easier way?  :-[

You have to make the jump to writing Plugins though.

Baby steps...

D

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5262
  • Made in England
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #12 on: October 08, 2015, 18:59:51 pm »
Dan,
This might be a useful thread for importing pickup cavity profiles etc. http://www.cambam.co.uk/forum/index.php?topic=5134.msg40325#msg40325
Filmed in Supermarionation

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #13 on: October 09, 2015, 06:05:28 am »
Dan,
This might be a useful thread for importing pickup cavity profiles etc. http://www.cambam.co.uk/forum/index.php?topic=5134.msg40325#msg40325

Yessir!  That's a fine utility.  I've already used it in combining my first freehand versions of the micro-bass body top and back drawings with the the file generated by the fret board modeler script I submitted earlier.  It'll sure come in handy if I ever find good DXF or other CB compatible drawings of useful parts like tuners and bridges too (as well as stock drawings of bodies, head stocks, neck profiles and the like).

Thanks for the tip.  :)

D

Offline HLMEI

  • Ewok
  • *
  • Posts: 16
    • View Profile
Re: Sloped Surface Following Polyline
« Reply #14 on: October 09, 2015, 07:07:24 am »
You have to make the jump to writing Plugins though.

The scripts I've been producing are already taking time away from my day job!!  :-X

Actually, at the moment I think I'm pretty tapped out on "things I need" to help me create the basics of a guitar/bass using CB.  It's time to put it all together and make some wood scraps.

I'll probably tweak the scripts I've created so far for a while before creating anything drastically new.  I still need to do little things like extend the strings in the fret board modeler out past the nut into the head stock to assist in tuner layout and add the logic for the corner radius = 0 thing you made me aware of.

I might add a neck profile function to lay out the basics for the "3D surface using Geoff's digitize plugin" method you pointed out.  I just need to get more familiar with it.  I thought I might use pixelmaker's method to import various common neck profiles from images on the web into sort of a DB of profiles in the modeler.  I'm just trying to figure out how I want to store the profile curves (C, U, Vee, asymmetrical, etc) so I can just pick one and have the tool scale it and drop it into the right places.

Seems like I should do a step-by-step on how I created a bass using lessons learned on this forum.  I'll keep a journal...

Should I say I was daring to hope someone here might find these scripts intriguing enough to make suggestions for improvement or that someone might rewrite the useful one as a plugin as I've seen some do here?  That would be cool but I don't know if I need it for my own work here.

I will say I find the general welcome and helpfulness from you and the others I've interacted with here to be really refreshing and even inspiring.  You may yet convince me to try my hand at writing a plugin...

Thanks again!

D