DrawFromCSV - adding ellipses
Posted: Wed Jan 25, 2023 11:34 pm
If I can just add a little capability to the DrawFromCSV package, QCAD is going to be a fantastic solution to my project.
Win 10, QCAD 3.27.9.0 build date Jan 16 2023
I need to add the ability to draw ellipses and elliptical paths from data in CSV files.
The demo works fine, and has a section for drawing a circle and I am using that as a code source. My googling is turning up nothing useful. This should be simple but I am unable to add a section of code for an ellipse.
existing code:
case "CIRCLE":
// Create new circle shape:
try {
refRv = new RVector(parseFloat(fields[1]), parseFloat(fields[2]));
newShape = new RCircle(refRv, parseFloat(fields[3]));
}
catch(err) { // On an error reset shape:
newShape = undefined;
}
break;
one of the many things I tried:
case "ELLIPSE":
// Create new ellipse shape:
try {
refRv1 = new RVector(parseFloat(fields[1]), parseFloat(fields[2]));
refRv2 = new RVector(parseFloat(fields[3]), parseFloat(fields[4]));
refRv3 = new RVector(parseFloat(fields[5]), parseFloat(fields[6]));
newShape = new REllipse(refRv1,refRv2,refRv3);
}
catch(err) { // On an error reset shape:
newShape = undefined;
}
break;
with the following line 43 added to the bottom of the demo's CSV file:
ellipse,50.0,50.0,75.0,75.0,90.0,90.0
because it looks like the ellipse command wants three coordinates, and three vectors should supply that.
Obv I do not know what I am doing with the javascript.
I get "not a correct entry, line 43"
I am not finding anything in my searches to guide me on the actual javascript. I tried lots of things, I just posted this to get started.
TIA
Win 10, QCAD 3.27.9.0 build date Jan 16 2023
I need to add the ability to draw ellipses and elliptical paths from data in CSV files.
The demo works fine, and has a section for drawing a circle and I am using that as a code source. My googling is turning up nothing useful. This should be simple but I am unable to add a section of code for an ellipse.
existing code:
case "CIRCLE":
// Create new circle shape:
try {
refRv = new RVector(parseFloat(fields[1]), parseFloat(fields[2]));
newShape = new RCircle(refRv, parseFloat(fields[3]));
}
catch(err) { // On an error reset shape:
newShape = undefined;
}
break;
one of the many things I tried:
case "ELLIPSE":
// Create new ellipse shape:
try {
refRv1 = new RVector(parseFloat(fields[1]), parseFloat(fields[2]));
refRv2 = new RVector(parseFloat(fields[3]), parseFloat(fields[4]));
refRv3 = new RVector(parseFloat(fields[5]), parseFloat(fields[6]));
newShape = new REllipse(refRv1,refRv2,refRv3);
}
catch(err) { // On an error reset shape:
newShape = undefined;
}
break;
with the following line 43 added to the bottom of the demo's CSV file:
ellipse,50.0,50.0,75.0,75.0,90.0,90.0
because it looks like the ellipse command wants three coordinates, and three vectors should supply that.
Obv I do not know what I am doing with the javascript.
I get "not a correct entry, line 43"
I am not finding anything in my searches to guide me on the actual javascript. I tried lots of things, I just posted this to get started.
TIA