new dovetail script
Moderators: andrew, Husky, J-J
new dovetail script
Changelog: I removed the old, defect script from this post and added a working copy at the end of this thread.
My goal was to create a dovetail script with the following parameters:
- number of dovetails,
- height of dovetail,
- dovetail gradient (usually 7:1, 6:1, 5:1 and 4:1)
- dovetail/pin ratio
By selecting start and end point, you define the width of the board.
First let my say, that I am not a javascript programmer, and I have no clue how all this QCAD scripting works.
I took the boxjoint script from Matthias Melcher and tried to implement the mathematical calculations for the dovetails.
I have tried my best during the last 3 days to come up with a working dovetail script, but I have failed. I get no errors but noting is drawn on the screen.
Maybe someone with more scripting knowledge can have a look at the script and find out, why it does not work.
I have attached a drawing so it is easy to figure out, what the variables in the script relate to.
My goal was to create a dovetail script with the following parameters:
- number of dovetails,
- height of dovetail,
- dovetail gradient (usually 7:1, 6:1, 5:1 and 4:1)
- dovetail/pin ratio
By selecting start and end point, you define the width of the board.
First let my say, that I am not a javascript programmer, and I have no clue how all this QCAD scripting works.
I took the boxjoint script from Matthias Melcher and tried to implement the mathematical calculations for the dovetails.
I have tried my best during the last 3 days to come up with a working dovetail script, but I have failed. I get no errors but noting is drawn on the screen.
Maybe someone with more scripting knowledge can have a look at the script and find out, why it does not work.
I have attached a drawing so it is easy to figure out, what the variables in the script relate to.
- Attachments
-
- Dovetail_Calculation.dxf
- (109.25 KiB) Downloaded 880 times
Last edited by caigner on Thu Feb 16, 2017 12:53 pm, edited 1 time in total.
QCAD Pro on Gentoo Linux
Re: new dovetail script
First, please make sure that your script has a unique name, for example LineDove2. All your files and the class defined inside have to use that same name.
I can see that your script produces lines which cannot be shown because they have invalid coordinates.
Here are some tips for debugging:
- Use qDebug(...) statements to print variables, for example:
qDebug("myVector: ", myVector);
- Alternatively, use EAction.handleUserMessage(...) to print information to the QCAD command line history.
- Start QCAD with the command line argument -enable-script-debugger and place a debugger statement to stop your script at that line and show a debugger which you can use to step through code, observe variables, set variables, etc:
debugger;
Note that the script debugger can lead to crashes due to immediate event processing, so this should really only be used if you intend to debug a script.
I can see that your script produces lines which cannot be shown because they have invalid coordinates.
Here are some tips for debugging:
- Use qDebug(...) statements to print variables, for example:
qDebug("myVector: ", myVector);
- Alternatively, use EAction.handleUserMessage(...) to print information to the QCAD command line history.
- Start QCAD with the command line argument -enable-script-debugger and place a debugger statement to stop your script at that line and show a debugger which you can use to step through code, observe variables, set variables, etc:
debugger;
Note that the script debugger can lead to crashes due to immediate event processing, so this should really only be used if you intend to debug a script.
Re: new dovetail script
Thanks! I have used qDebug() to find out, what values my parameters have, and I found out, that they are all "undefined".
So my problem is, that I don't know, how to get values from the UI to the script.
For example, I can input "Number of Dovetails", but the value is not transfered to the script.
Any suggestions? How do I access input parameters in the script?
So my problem is, that I don't know, how to get values from the UI to the script.
For example, I can input "Number of Dovetails", but the value is not transfered to the script.
Any suggestions? How do I access input parameters in the script?
QCAD Pro on Gentoo Linux
Re: new dovetail script
Whenever the user changes the values in the UI, a signal is fired which calls the corresponding slot in your class. The slot name is fixed and contains the name of the object in the UI file. For example, for your input "DovetailNumber", the signal "slotDovetailNumberChanged" is called, etc.
You can use qDebug again to check if these slots are called correctly. You might also want to have a look at the other scripts that come with QCAD for plenty of example code.
You can use qDebug again to check if these slots are called correctly. You might also want to have a look at the other scripts that come with QCAD for plenty of example code.
Re: new dovetail script
Ok, this problem is solved. It was an uppercase/lowercase problem.
Now something is drawn, but it doesn't look like a dovetail. The lengths are correct, but the angle of two lines is not.
Now something is drawn, but it doesn't look like a dovetail. The lengths are correct, but the angle of two lines is not.
QCAD Pro on Gentoo Linux
Re: new dovetail script
I am sooo close to finishing this script.
The dovetails are drawn correctly, but at the end of the second mouse click.
The dovetails are drawn correctly, but at the end of the second mouse click.
QCAD Pro on Gentoo Linux
Re: new dovetail script
I proudly present: The Dovetail Script v2.0
Thanks to Matthias Melcher for his first dove tail script, which inspired me to follow in his steps.
And thank you, Andrew, for your help.
Please feel free to include this dovetail script in the next QCAD release.
Thanks to Matthias Melcher for his first dove tail script, which inspired me to follow in his steps.
And thank you, Andrew, for your help.
Please feel free to include this dovetail script in the next QCAD release.
- Attachments
-
- LineDove2.zip
- (6.21 KiB) Downloaded 877 times
QCAD Pro on Gentoo Linux
Re: new dovetail script
Bonus: When entering a dovetail gradient of 9999 or higher you get a fine finger joint with ≤0,005 mm error, with half fingers at the ends.
QCAD Pro on Gentoo Linux
Re: new dovetail script
Excellent, thanks! Looks great from what I've seen so far
Your script will be included in future QCAD releases and now lives at:
https://github.com/qcad/qcad/tree/maste ... /LineDove2
Your script will be included in future QCAD releases and now lives at:
https://github.com/qcad/qcad/tree/maste ... /LineDove2
Re: new dovetail script
Congratulation!caigner wrote:I proudly present: The Dovetail Script v2.0
Should this script replace the old one? If not we have the same name twice ...
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."
Re: new dovetail script
I think the old dovetail script started as an example for scripting in QCAD. It didn't do more than draw one dovetail of fixed geometry.
I suggest to move the old script to the example scripts and replace it in its current place with my new one.
I suggest to move the old script to the example scripts and replace it in its current place with my new one.
QCAD Pro on Gentoo Linux
Re: new dovetail script
caigner: yes, agreed.