OS: Windows 7x64, QCAD 3.25.2.
I need auto-draw some lines to drawing, but can't find example of minimal script. Would someone give me example or link to example?
Task is very easy: make line x1,y1 to x2, y2, then to x3,y3 and so on. Script will be generated by other software.
Need script example [solved]
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Need script example [solved]
Last edited by jooogger on Sun Feb 07, 2021 10:18 pm, edited 1 time in total.
Re: Need script example
Have a look at:
https://qcad.org/en/tutorial-script-programming
And in particular:
https://qcad.org/en/tutorial-the-script-shell
https://qcad.org/en/tutorial-script-programming
And in particular:
https://qcad.org/en/tutorial-the-script-shell
Re: Need script example
Here's the first script I've written for QCAD! It may be a terrible approach I put the points in the variable pointStr, where each point is separated by a slash, and each coordinate by a comma. That should make it easy to generate your own string (depending on your source data). The code and data structure will need to be revised if your locale uses commas instead of periods to specify decimals.jooogger wrote: ↑Sun Feb 07, 2021 3:05 pmOS: Windows 7x64, QCAD 3.25.2.
I need auto-draw some lines to drawing, but can't find example of minimal script. Would someone give me example or link to example?
Task is very easy: make line x1,y1 to x2, y2, then to x3,y3 and so on. Script will be generated by other software.
What I learned is that the ecma used by Qcad doesn't support the x of array syntax that would have made the task easier.
Code: Select all
pointStr="0,0/5,5/11,3/-3,6,7" ;
pointSet = pointStr.split("/") ;
var pt = pointSet[0] ;
var p1 = [ pt.split(",")[0] , pt.split(",")[1] ] ;
for ( i=1 ; i<pointSet.length; i++) {
pt=pointSet[i] ;
p2 = [ pt.split(",")[0] , pt.split(",")[1] ] ;
addLine(p1,p2) ;
p1 = p2 ;
}