Dear All,
I posted a couple of threads here to help me along the way, but since I today got a working script done, I decided to post a new thread to keep everything gathered. Please check "Point3D to coordinates" and "Add a Command" for previous bits and pieces.
The boggle:
I am trying to make a simple script that will take a selected curve and based on that generate a MCR script that can be used to control Datron CNC Mills. Of course anyone familiar with their own CNC scripting, such as G-code, can easily adapt the script.
This is because sometimes I need something that will run those idiotically simple milling operations that are near impossible to program on the CNC or with traditional CAM software, which are easier to use but harder to control. I don't see this script becoming a tool for everyone, but another tool in the box for some of us.
Please note that I am a complete novice in Python, so the code is very messy and not very optimized. I am sure I have made every programmers heart weep by making the code unreadable, but I have tried my best to comment. Also note that quite a bit of the code is adapted from Steves code posted on this forum, a big thank you.
What works:
Right now, you can select a curve, define how many sections the curve is divided into and output a list of valid Axyz commands to the Command History Window, with the origo defining the zero point. The script also solves the highest Z of the curve, adds 15mm and uses this as the safe height for both engage and retract.
Whats missing:
- No start block, meaning no controls over Feeds, toolnumbers, RPM or anything else. Ideally this would be decided by the user by either tool data or by manually entering the info, but a simple hardcoded block should be easy.
- Currently only works with mm, i think. And the Datron needs to be set to mm as well.
- No saving the MCR script, except from the Command History dialogue
- No multiple curves
- The Command Histroy window only shows 80 lines or so, perhaps not enough for the whole machine code.
- The coordinates should always have 3 decimals, as some machines require this, but rounding 0.000000000001 and using str() results in 0.0, dont know what to do.
- Messy, Messy code. Should write everything into neat little functions that return the required values.
Anyway, I am including this here and I will try to update it as I get the time. If someone wishes to participate, I welcome all help, and if someone (except me) learns something from this, all the better. I take no responsibility if someone runs their mill into their toolbox, If you cant read MCR or G-code and check the output, don't use it.
All the best,
Aalto


Reply With Quote
