OS: Arch linux
QCAD Professional 3.27.6.0
So here is my idea - Customer sends me a pdf or dwg file of a part they want me to fabricate. I want to have a script that scrapes that dwg or pdf for the dimensions I need (in this example its always a standard flange for a pipe so only dimensions I need are OD, BC, ID, and hole size) and putting that data in the relevant JavaScript code to make it a script for QCAD, open QCAD and run the QCAD portion of the script. I want the javascript portion for QCAD to draw the part, and save the part as “part1234.dxf” to a specific folder. I plan on writing this mainly in Python except for the portion where it needs to be js for QCAD scripting.
I started on drawing a mock part with a script already. I figured I wanted to get the qcad script down first before I start on the rest. Here is that code. I have literally never used JavaScript in the past so be gentle. Please point out if there is a better way to do what I am trying to do with this drawing. Basically in the past when I draw these parts up manually in QCAD I make my OD circle, BC circle, ID circle, and hole circle. Then I move the hole to a center reference point on the BC circle, go to modify > move and rotate > and make however many copies I need (usually
and set the relevant angle. The end result is a flange with 8 (usually) evenly spaced holes around the BC. Thats what I want to accomplish with the script. I couldn’t figure out how to script the move/rotate portion of the process so in the code you will see my work around. Again, totally hoping someone has some suggestions on how to do it better. Also I cant figure out how to save the drawing as a dxf to a specific directory. Hoping someone can help me on that as well.
Code:
include(“scripts/EAction.js”);
include(“scripts/File/SaveAs/SaveAs.js”)
addLayer(“OD”)
addLayer(“BC”)
addLayer(“ID”)
addLayer(“HOLES”)
circle_od = addCircle(0, 0, 3)
circle_id = addCircle(0, 0, 1.75)
circle_hole = addCircle(1.75, 0, .25)
rotate(circle_hole, angle = 45)
circle_hole2 = addCircle(1.75, 0, .25)
rotate(circle_hole2, angle = 90)
circle_hole3 = addCircle(1.75, 0, .25)
rotate(circle_hole3, angle = 135)
SaveAs(‘flngscripttest.dxf’)
Again, complete novice here. What I have there ^ was me totally going in blind just trying to get a drawing similar to what I need on the screen, which that code accomplishes that. I am stuck on finding the legit way to move/rotate and copy my holes and how to save the drawing as a relevant .dxf file in the directory I need. Also if there is any guidance on how I can get Python to automatically read the customers dwg and pdf and spit out that code ^ into a .js file and open QCAD and run the script (all automatically from the python script) that would be great. If I have to use 100% javascript to do it all please let me know.
I am writing the code in a text editor and then opening the script from QCAD Misc > Development > Run Script
Thanks for reading.