CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2019, 03:02:39 am


Login with username, password and session length


Pages: 1 ... 5 6 [7] 8
  Print  
Author Topic: Drag-Knife Script  (Read 60678 times)
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 4057



View Profile
« Reply #90 on: June 13, 2019, 09:30:09 am »

Dave,

billT wrote the original script, I just made it inot a plugin so I've never really looked at how it works.
It's about 6 months since Bill last logged into the forum, I'm in the middle of repairing a digital piano and so it might have to wait a while before I get to dig deeper.
Thanks for the files and explanation.
Logged

Made in England
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #91 on: June 13, 2019, 09:38:57 am »

No Worries Eddy.
I found a Quite except-able way to do this with a profile mop that starts to spiral down from a small distance
above work surface (this automatically aligns the knife) and this works wonderfully for me, so I wont be needing the Drag Knife plugin to make any of my gaskets.
piano or synth?.
Dave
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 4057



View Profile
« Reply #92 on: June 13, 2019, 13:48:06 pm »

Dave,

So does the knife still rise up, but stay in the material at the corners to allow turning, and then drop down again full depth for cutting ?

It's quite an old but good quality Kawai digital piano, lots of faults thanks to previous owner and the age of the boards, but we are getting there now.
Logged

Made in England
pixelmaker
CNC Jedi
*****
Offline Offline

Posts: 1714


View Profile WWW
« Reply #93 on: June 13, 2019, 16:05:29 pm »

Dave, you have to adjust the "Swivel Angle"
I never used this plugin because I have a large cutting plotter. But I've already successfully created code with it.

If you have a circle you have to add some points and reduce the Swivel Angle, in this case to 0.2.

The toolpath works as expected, starts and end at the swivel points

ralf


* Bildschirmfoto 2019-06-13 um 16.43.29.png (24.78 KB, 187x353 - viewed 105 times.)

* Bildschirmfoto 2019-06-13 um 16.59.50.png (70.65 KB, 743x488 - viewed 117 times.)
* drag knife01.cb (73.21 KB - downloaded 63 times.)
« Last Edit: June 13, 2019, 16:07:21 pm by pixelmaker » Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #94 on: June 14, 2019, 01:12:33 am »

Thanks for the heads up Ralf.

I tried your file and even entered some new geometry everything went as expected, I then tried my file again and got a different result my previous result, (I think something is screwy with the file) so I'll try Later today  and see how I go.

Eddy here's a picture of one of the corners done with the profile mop, it looks good and so do the other cuts.
I think that for material this thin 0.3 mm the raising and lowering is not necessary, but could see that on thicker material
would be a great help.

I have a home made huge in comparison Drag Knife for cutting out neoprene gaskets (2 mm thick) and will do some more tests as soon as I machine down the shank to fit in my collet system, it has a large offset in comparison, and this is where I think the swivel action would be useful.

Eddy sadly the day they were handing out musical talent I was away, and one of my younger brothers got a double dose.
He makes acoustic guitars, using different wood varieties for various parts, which he keeps in a climate controlled box.
I offered to cut out some parts out for him, But he'll have none of it, as he uses mostly hand equipment collected over the years.
He has one of the smallest wood planes I've ever seen IIRC he called it a finger plane. It looks like a plane in miniature not a spoke shave.

Dave


* Ralfs file ok.PNG (57.52 KB, 863x492 - viewed 116 times.)

* My File CB ver 1.PNG (218.18 KB, 1263x564 - viewed 100 times.)

* Drag Knife Close up of corner.jpg (221.94 KB, 1280x1024 - viewed 100 times.)
Logged
pixelmaker
CNC Jedi
*****
Offline Offline

Posts: 1714


View Profile WWW
« Reply #95 on: June 14, 2019, 10:23:28 am »

Hello Dave
I get the error messages if Swivel Angle is wrong. You have to set the value partially for each object.
Please upload a file, then I'll set it for you.

The material looks like you couldn't cut it with a knife, but the magnification can be misleading..

ralf
« Last Edit: June 14, 2019, 10:25:18 am by pixelmaker » Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #96 on: June 14, 2019, 15:48:38 pm »

Thanks for the offer Ralf I really appreciate it, But I've had a look at the Python code and can see the problem.
In  line 129
CFirstSweep = Math.Acos(round(Vector2F.DotProduct(VFirst,V1)/(VFirst.Length*V1.Length),10))
The vector v1.length is NAN which gives a divide by zero error.
there is no error checking for this.
In line 152
        C2X = P2X+KnifeTipOffset/((1+(V2.Y/V2.X)**2)**.5)*Math.Sign(V2.X)
V2.X is NAN as well

As it is for this gasket making task the profile mop is far better for me as I can use holding tabs to keep the material from moving around.
So first I cut the circles (bolt holes) then cut the inside island using holding tabs to stop the material from moving around and getting stuck under the knife, then cutting the outside periphery last using holding tabs again.

The image in the last post was at X10 magnification and this pic below has a writing pen in it  to get some sense of the scale.
The second pic is of the edge of the gasket material to show just how brittle it is, I won't be actually using it in the turrets as it is no good for gaskets anymore.

I realise that the method I use would be no good for a vinyl cutter where the wheeling paths would be beneficial and perhaps working with the 2-3 mm neoprene gaskets I intend to make later on.

When the time comes and I need to use the wheeling paths then I'll write some new C# code from first principles using the website Bill pointed to.

Dave

Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #97 on: June 17, 2019, 12:17:50 pm »

Ralf
I got minute today to add checking for the divide by zero error.
Could you have a look at this CB file and check the geometry (it looks OK to me).
If it looks good than I'll post the change I made so Eddy can add this to the plugin.
edit can't spell looks Roll Eyes
Dave

* Drag Knife Examples.cb (43.49 KB - downloaded 50 times.)
Logged
pixelmaker
CNC Jedi
*****
Offline Offline

Posts: 1714


View Profile WWW
« Reply #98 on: June 18, 2019, 16:24:51 pm »

The geometry is ok.
Most problems occur with circles.
Only there the error occurs with me so massively on that I must adapt the Swivel Angel.
Therefore test preferably with circles

ralf
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #99 on: June 19, 2019, 00:40:24 am »

Yes it's the tangent thing. Atan2 has some quirks but may be needed. Don't know yet just have to play around and see.
On the week end I'll see if something can be done, but don't hold your breath as
I'm flat out making parts in the shop, and am struggling to keep up.
Dave
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #100 on: June 20, 2019, 01:46:54 am »

Hi Ralf

I tinkered a bit more, and added a few lines to the script.
I can do circles without a problem, if I select those first and process them as a group, then select the other text geometry and do that separately.
The issue is that you have to remove the Arc's in the polyline.
Interestingly if you use that same geometry again the script fails.
and the items that you selected, for example 5 circles, they stay selected in the tree view, but in reality only the last circle in the selected group is selected, if you immediately do a rmb click and move the objects only the last polyline in the group moves, even though all the polylines are showing as selected in the tree view and in the drawing area?

So for now if you select the circles and convert them to polylines with CB, then remove the Arc's and run the original script on (no other geometry is allowed) them they'll be OK.
Then just run the original script on the rest of the geometry.

Dave


* success sort of.PNG (264.12 KB, 1349x591 - viewed 93 times.)
Logged
pixelmaker
CNC Jedi
*****
Offline Offline

Posts: 1714


View Profile WWW
« Reply #101 on: June 20, 2019, 12:49:37 pm »

Hallo Dave

after my tests it is enough to provide the circles and arcs with more nodes.
In CamBam a circle has 2 or 3 nodes if you convert it to a polyline. If you increase the number to more nodes there is no error. The distance of the nodes seems to be more important than the number. If the distance of the nodes in a circle is only 5-6mm there is no error.
But arcs remain arcs.

ralf
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #102 on: June 20, 2019, 14:20:54 pm »

HI Ralf

Interesting I hadn't tried that, I found out what was causing the script to fail on the second attempt (after the first try failed)
it hadn't failed completely the first time as the geometry was placed at Z-1 (the setting I had in the script).
When I put the geometry back at Z = 0 it worked again.
I also made this change to the script, but forgot to mention it in the previous post.
I had a look at an old textbook of vector math to swat up a bit as I've forgotten a lot of the details.
The divide by zero error I was sometimes getting was caused by the cross product calc.
what happens is the cross product is a magnitude and an angle between them and if the two vectors lay on top of each other
the angle = 0 , so I added these two lines to the script.

  #### Remaining Segments - Calculate Cut Points (C1,C2) and Cut Segment Bulge (C1B)

      C1 = Point2F(P1X+V1.X*KnifeTipOffset,P1Y+V1.Y*KnifeTipOffset)

      if seg.GetType().Name == "XPolySegLine":     
        C1B = 0
        C2 = Point2F(P2X+V2.X*KnifeTipOffset, P2Y+V2.Y*KnifeTipOffset)

      elif seg.GetType().Name == "XPolySegArc":
        C1B = Math.Tan(seg.Sweep/4)
        if V2.X == 0:
           Vector2F.X.SetValue(V2,1)

        C2X = P2X+KnifeTipOffset/((1+(V2.Y/V2.X)**2)**.5)*Math.Sign(V2.X)
        C2Y = P2Y+(KnifeTipOffset*V2.Y/V2.X)/((1+(V2.Y/V2.X)**2)**.5)*Math.Sign(V2.X)
        C2 = Point2F(C2X,C2Y)

I also found this script at the DXF2Gode site, it's originally Bill's script from here, where they also had to modify the script
to get it to work for them.
So might provide some clues for us.

Code:
     def make_swivelknife_move(self):
         """
         Set these variables for your tool and material
         @param offset: knife tip distance from tool centerline. The radius of the
         tool is used for this.
         """



         offset =self.shape.LayerContent.tool_diameter/2
         dragAngle = self.shape.dragAngle

         startnorm = offset*Point(1,0,0)
         prvend, prvnorm = Point(0,0),Point(0,0)
         first = 1


         #start = self.startp

         #Use The same parent as for the shape
         self.parent=self.shape.parent

         for geo in self.shape.geos:
             if geo.type == 'LineGeo':
                 geo_b = deepcopy(geo)
                 if first:
                     first = 0
                     prvend = geo_b.Pa + startnorm
                     prvnorm = startnorm
                 norm = offset*geo_b.Pa.unit_vector(geo_b.Pe)
                 geo_b.Pa += norm
                 geo_b.Pe += norm
                 if not prvnorm == norm:
                     swivel = ArcGeo(Pa=prvend, Pe=geo_b.Pa, r=offset,direction=prvnorm.cross_product(norm).z)
                     swivel.drag = dragAngle < abs(swivel.ext)
                     self.geos.append(swivel)
                 self.geos.append(geo_b)

                 prvend = geo_b.Pe
                 prvnorm = norm
             elif geo.type == 'ArcGeo':
                 geo_b = deepcopy(geo)
                 if first:
                     first = 0
                     prvend = geo_b.Pa + startnorm
                     prvnorm = startnorm
                 if geo_b.ext > 0.0:
                     norma = offset*Point(cos(geo_b.s_ang+pi/2),sin(geo_b.s_ang+pi/2))
                     norme = Point(cos(geo_b.e_ang+pi/2), sin(geo_b.e_ang+pi/2))
                 else:
                     norma = offset*Point(cos(geo_b.s_ang-pi/2), sin(geo_b.s_ang-pi/2))
                     norme = Point(cos(geo_b.e_ang-pi/2), sin(geo_b.e_ang-pi/2))
                 geo_b.Pa += norma
                 if norme.x > 0:
                     geo_b.Pe = Point(geo_b.Pe.x+offset/(sqrt(1+(norme.y/norme.x)**2)),geo_b.Pe.y+(offset*norme.y/norme.x)/(sqrt(1+(norme.y/norme.x)**2)))
                 elif norme.x ==0:
                     geo_b.Pe = Point(geo_b.Pe.x,
                         geo_b.Pe.y)
                 else:
                     geo_b.Pe = Point(geo_b.Pe.x-offset/(sqrt(1+(norme.y/norme.x)**2)), geo_b.Pe.y-(offset*norme.y/norme.x)/(sqrt(1+(norme.y/norme.x)**2)))
                 if not prvnorm == norma:
                     swivel = ArcGeo(Pa=prvend, Pe=geo_b.Pa, r=offset, direction=prvnorm.cross_product(norma).z)
                     swivel.drag = dragAngle < abs(swivel.ext)
                     self.geos.append(swivel)
                 prvend = geo_b.Pe
                 prvnorm = offset*norme
                 if -pi<geo_b.ext<pi:
                     self.geos.append(ArcGeo(Pa=geo_b.Pa, Pe=geo_b.Pe, r=sqrt(geo_b.r**2+offset**2), direction=geo_b.ext))
                 else:
                     geo_b = ArcGeo(Pa=geo_b.Pa, Pe=geo_b.Pe, r=sqrt(geo_b.r**2+offset**2), direction=-geo_b.ext)
                     geo_b.ext = -geo_b.ext
                     self.geos.append(geo_b)

             else:
                 self.geos.append(copy(geo))
         if not prvnorm == startnorm:
             self.geos.append(ArcGeo(Pa=prvend, Pe=prvend-prvnorm+startnorm, r=offset, direction=prvnorm.cross_product(startnorm).z))

         self.geos.insert(0,self.geos[0].Pa)


Why I originally removed the Arc's was that the code as is was sometimes adding the geometry to the wrong end of the Arc.
I'm subed to 3Blue1brown where he has a series of Math videos, and I know he did Vectors, so on the weekend I'll look at a few jog my memory.

Dave
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1153


View Profile
« Reply #103 on: June 30, 2019, 01:53:29 am »

Ralf

I had a chance to have another quick look, Math is OK, and found the the code fails when the
circles are quite small, which meant that the segments were larger than the knifeTipoffset value.
I found that when I set the Arc tolerance to small the segment lengths were smaller than the knife tip offset value
and this caused many swivel movements (dent length set to zero) I could remove them if I set the
Angle value, so the parameter settings are  dependent on each other. I did trap for this but, to set the parameter bounds I need a typical file that you might use on a plotter.
So when you get some time, could you please post a test file with some real geometry, so that I can determine the
bounds for the variables.

Dave
Logged
andy_con
Storm Trooper
***
Offline Offline

Posts: 106


View Profile
« Reply #104 on: October 11, 2019, 14:59:29 pm »

could i get some help.

when in cambam and i open scripts, its looking in folder c drive, program files etc...

but when i go into c drive and program files, cambam isnt there?

cambam is under program file x86, but there isnt a script folder.
Logged
Pages: 1 ... 5 6 [7] 8
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.155 seconds with 19 queries.

Copyright © 2018 HexRay Ltd. | Sitemap