Author Topic: Creating spline from python script  (Read 2178 times)

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6489
    • View Profile
    • Cambam V1.0 French Doc
Re: Creating spline from python script
« Reply #15 on: January 26, 2021, 20:33:10 pm »
Daviddala, thank you for creating this script, by looking on the pictures it shure looks nice. My problem is, I can not get it working for me. F5 key should run it after inputting parameters, right?

If is another way for this script to execute I don't know what it is. I also work with inch units, is that maybe a problem?

Best..

have you seen this message ?
https://cambamcnc.com/forum/index.php?topic=8921.msg70639#msg70639

++
David

Offline davidala

  • Ewok
  • *
  • Posts: 10
    • View Profile
Re: Creating spline from python script
« Reply #16 on: January 26, 2021, 20:54:15 pm »
Well spotted David - edited earlier post to remove the misleading .py

I see, so I can just copy the whole script into the script field but adapted so its not written as a function.  How would I then get parameters into it through the UI?

Cheers
David A
Win10 (64bit),  CamBam1 (64 bit),  Duet3D,  WorkbeeCNC

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4739
    • View Profile
Re: Creating spline from python script
« Reply #17 on: January 26, 2021, 21:00:58 pm »
Put the parameters together at the start of the script then people just change the numbers themselves before pressing F5

There are some sample scripts here; https://cambamcnc.com/ref/
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6489
    • View Profile
    • Cambam V1.0 French Doc
Re: Creating spline from python script
« Reply #18 on: January 26, 2021, 21:03:38 pm »
Quote
How would I then get parameters into it through the UI?

With python, I don't know ; I only use VB script that have an "InputBox" function.

++
David


Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3145
    • View Profile
Re: Creating spline from python script
« Reply #19 on: January 26, 2021, 22:59:02 pm »
Bubba,
I have not tried this script, yet.  But how about if you just try to run it as 'metric', then convert the drawing to inch units after it's done.

If it works then, you know it's 'units' causing the issue.

Lloyd

Thanks for that Lloyd, I didn't event think of this. Good idea.
My 2¢

Win10 (64 bit, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, Endurance Laser.

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3145
    • View Profile
Re: Creating spline from python script
« Reply #20 on: January 26, 2021, 23:04:50 pm »
Quote
I noticed your comment about it not being a "normal" script but not sure what that is.

A script can be run by the menu Script/open ...

++
David

That's how I run/open scripts.
My 2¢

Win10 (64 bit, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, Endurance Laser.

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3145
    • View Profile
Re: Creating spline from python script
« Reply #21 on: January 26, 2021, 23:22:55 pm »
I guess I'm to dense, After multiple attempts putting numbers in different colored fields (at least what I thought what it was) I can't get this to work.

Thank you all anyway.
My 2¢

Win10 (64 bit, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, Endurance Laser.

Offline BR52

  • Wookie
  • ****
  • Posts: 351
    • View Profile
Re: Creating spline from python script
« Reply #22 on: January 27, 2021, 00:01:15 am »
Hi
The great example is in David's puzzle.cb file (dh42), you don't need F5.
The puzzle.py file is already installed in the CamBam script folder.
See attached image, change and OK and save puzzlle.cb
Look here: https://cambamcnc.com/forum/index.php?topic=8921.msg70643#msg70643

   Armando

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3145
    • View Profile
Re: Creating spline from python script
« Reply #23 on: January 27, 2021, 04:18:16 am »
Finally, Thanks to all I got it. I need to tweak some parameters but over all I'm happy. Yes I used inch units as well.
My 2¢

Win10 (64 bit, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, Endurance Laser.

Offline davidala

  • Ewok
  • *
  • Posts: 10
    • View Profile
Re: Creating spline from python script
« Reply #24 on: January 30, 2021, 13:40:33 pm »
I built a couple of jigsaws from 3mm birch ply using this and a 1mm end mill (engraving MOP) taking it very carefully .  It made me realise that even a 1mm clearance is a bit too much unless the puzzle pieces are very large.
To get a smaller clearance between pieces means creating two identical puzzle blanks that can be identically registered on the cutting table and then cutting odd pieces on one blank and even pieces on the other with a suitable profile offset.
This is fairly easily achieved by exploding the created script object; Converting to polylines;  Breaking at intersections and then joining the edge segments to give closed polylines round the individual pieces.  The problem doing this with a script object is that the original script call gets overwritten (at least I haven't spotted a way to avoid that).
So given that problem and also that most people seem to be familiar with a script run from the script/open menu, I have produced another version of the puzzle script to be runnable from the script/open menu and to also take some of the extra steps necessary.

I still don't know:
1) how to make sure the selected layer is the active layer and rename it ("puzzle evenpieces")
2) how to create a new layer and name it ("puzzle oddpieces")
3) how to copy the puzzle polylines to the new layer

so any pointers  would be appreciated.

I have also fixed a bug to do with the randomisation.
I have attached latest version of both forms of the script.

Cheers
David A
« Last Edit: January 30, 2021, 14:35:16 pm by davidala »
Win10 (64bit),  CamBam1 (64 bit),  Duet3D,  WorkbeeCNC

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6489
    • View Profile
    • Cambam V1.0 French Doc
Re: Creating spline from python script
« Reply #25 on: January 30, 2021, 16:04:09 pm »
Hello

I can't help with python syntax, but maybe you can find some info and "translate" from VB script

Here are some code snippets

https://cambamcnc.com/forum/index.php?topic=3878.0

++
David

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3145
    • View Profile
Re: Creating spline from python script
« Reply #26 on: January 30, 2021, 20:21:36 pm »
Today was able to laser the puzzle created by this plugin. Must say, after get it to point of understanding how it works it was nice to see what it does. One small problem I can't not overcome is the border part, it draws big corner radius even though 0.125 inch" it was set at. This does not affect the end result, Just explode the created polylines, delete the original border and draw rectangle in its place. After locating good enough cardboard to print picture on it I lasered polylines.  It turns out pretty good, the image on the other hand needs lots of help because ink smufges.
My 2¢

Win10 (64 bit, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, Endurance Laser.

Offline davidala

  • Ewok
  • *
  • Posts: 10
    • View Profile
Re: Creating spline from python script
« Reply #27 on: January 31, 2021, 10:23:02 am »
Hi Bubba,
Really pleased that worked for you.
I imagine that burns/smudging are one of the real challenges of using a laser but at least you get narrow cuts in one pass - I had to do 4 passes with a 1mm router cutter to get through 3mm birch ply!
For routers you really need to cut two pictures (odd and even pieces) which I am working on generating automatically now but it's quite difficult making progress as there are so few python examples (I only started with python because they were the only scripts that worked on my 64bit install but I now realise that the 32bit install allows the vb scripts to work).  One of the offshoots of the next step will be the way I do the border so hopefully that will also solve your border corner issue.

David A
Win10 (64bit),  CamBam1 (64 bit),  Duet3D,  WorkbeeCNC

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3145
    • View Profile
Re: Creating spline from python script
« Reply #28 on: January 31, 2021, 12:27:41 pm »
I imagine that burns/smudging are one of the real challenges of using a laser but at least you get narrow cuts in one pass - I had to do 4 passes with a 1mm router cutter to get through 3mm birch ply!
*****************************

Hi Davidala,

Maybe I haven't described correctly, sorry. Actually the laser cutting was perfect, the smudges was created by my ink printer when printing on a cardboard that is 2mm thick. I'm using Epson 830 printer witch does have feed slot for this type material in the back. All I need to do is clean up really well before I use again for this kind of printing. Overall it all passed the test. ;D . I of figured by using router but you will use lots on material no matter how small the tool bit is.One way to combat this to profile each piece. My laser cut with is 0.008" so it good enough to do this sort of thing.
My 2¢

Win10 (64 bit, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, Endurance Laser.

Offline davidala

  • Ewok
  • *
  • Posts: 10
    • View Profile
Re: Creating spline from python script
« Reply #29 on: February 08, 2021, 22:09:14 pm »
I have now reworked both scripts:
1) puzzleobjv3p3:
      runs as an object and returns a single shape suitable for laser cut or router engrave with a very fine (1mm) bit
2) puzzlescriptv1p2:
     run from script/open menu.  Creates two additional layers for "odd" and "even puzzle pieces that can then be profiled on a router to give as small a clearance as you want between pieces. Be warned - this script deletes all existing layers in your drawing so only use on a new document.
Shapes of tabs are improved in both scripts.

The code may not be very elegant but trying to work out how to drive this in python given the very limited documentation/examples has been a bit of a trial (in more ways than one).
Should I be posting this here or somewhere else on this forum?

Cheers
David A
« Last Edit: February 08, 2021, 22:12:11 pm by davidala »
Win10 (64bit),  CamBam1 (64 bit),  Duet3D,  WorkbeeCNC