Hi,
I a metric guy and use a comma as separator, the semicolon is then my option to express a coordinate.
The Command Line is geared to and accepts a list of coordinates.
New Control Point Spline (SP), open, degree 3 with the next points and 'Done' afterwards draws the intended spline.
(I am about sure that originally these coordinate values are not limited to 8 decimals)
- 0,96802918; 4,09554303
0,97387637; 4,09519903
0,98155731; 4,09536022
0,99014236; 4,09546301
1,00816138; 4,09567873
1,02929573; 4,09482100
1,04156829; 4,09554303
When selected the Property Editor does not list Knot Vectors.
Save (Ctrl+S) and Revert reloads the file.
That reminds me of this topic (Unanswered, not fixed, bug report FS#2453 unattended
)
I now have a list of 9 Knot Vectors:
0 ; 0 ; 0 ; 1 ; 2 ; 3 ; 4 ; 4 ; 4
All are integer values like in
spline2.dxf.
Then I tried the next code in the Script Shell (
GE):
Code: Select all
var doc = EAction.getDocument();
var di = EAction.getDocumentInterface();
var controlPoints = [];
controlPoints.push(new RVector(0.96802918, 4.09554303));
controlPoints.push(new RVector(0.97387637, 4.09519903));
controlPoints.push(new RVector(0.98155731, 4.09536022));
controlPoints.push(new RVector(0.99014236, 4.09546301));
controlPoints.push(new RVector(1.00816138, 4.09567873));
controlPoints.push(new RVector(1.02929573, 4.09482100));
controlPoints.push(new RVector(1.04156829, 4.09554303));
var spline = new RSpline(controlPoints, 3);
var knots = spline.getKnotVector();
debugger;
var knots = [];
knots.push(3.55926049);
knots.push(3.55926049);
knots.push(3.55926049);
knots.push(3.28970036);
knots.push(3.28970036);
knots.push(3.28970036);
knots.push(2.72392481);
knots.push(2.72392481);
knots.push(2.72392481);
//spline.setKnotVector(knots); // # Ruled out CVH #
var splineData = new RSplineData(spline);
var splineEntity = new RSplineEntity(doc, splineData);
var op = new RAddObjectsOperation();
op.addObject(splineEntity);
di.applyOperation(op);
With ruling out the
spline.setKnotVector(knots) line I get the same Spline as in
spline2.dxf.
When not ruled out the transaction also reports a newly created ... Affected object besides object 5 (Model_Space Block).
But there is seemingly nothing in the drawing.
Except when you box select all inclusive around where it is expected AND including the origin.
A method to reveal Null-entities.
What is selected is not visible but it is a Spline with the intended Knot Vectors.
Save and Revert reloads the file, but the mysterious Spline was not saved and that without an error message in the nature of
"Object not saved".
Nor does AutoSave complains when we leave the file unsaved with the invisible Spline.
We are definitely missing something ...
For that I included reading out the Knot Vectors and halt in Debugger mode.
(No idea why this is not in plural)
Not functional in the Script Shell (
GE)
>>> Instruction lines are handled line by line.
Not functional when using Run Script (
XC) with the code saved as a JS script
>>> Execution is not halted.
... So I needed to merge the code in some QCAD script at hand ...
The knot list is empty at that point ...
In debugger mode pointing to the spline we see that it reports "Internal used Knots: 0 ; 0 ; 0 ; 1 ; 2 ; 3 ; 4 ; 4 ; 4"
Executing the next lines, with setting the knots list, we see that the intended knots are there but also that there is 1 more line ....

- SettingSplineKnot.png (39.37 KiB) Viewed 57484 times
Aargl! Including
var text = spline.toString(); then

It simplifies copy/paste too :
Code: Select all
"RSpline(RShape(address: \"0xd64c8f0\"), degree: 3, dirty: true, order: 4, closed: false, periodic: false, start point: \"RVector(0.018694, 3.048743, 0.000000, 1)\", end point: \"RVector(0.018694, 3.048743, 0.000000, 1)\", start tan: \"RVector(0.000000, 0.000000, 0.000000, 1)\", end tan: \"RVector(0.000000, 0.000000, 0.000000, 1)\", t_min: 0, t_max: 0,
controlPoints (7): 0: \"RVector(0.968029, 4.095543, 0.000000, 1)\", 1: \"RVector(0.973876, 4.095199, 0.000000, 1)\", 2: \"RVector(0.981557, 4.095360, 0.000000, 1)\", 3: \"RVector(0.990142, 4.095463, 0.000000, 1)\", 4: \"RVector(1.008161, 4.095679, 0.000000, 1)\", 5: \"RVector(1.029296, 4.094821, 0.000000, 1)\", 6: \"RVector(1.041568, 4.095543, 0.000000, 1)\", ,
weights (0): ,
fitPoints (0): ,
knots (9): 0: 3.55926, 1: 3.55926, 2: 3.55926, 3: 3.2897, 4: 3.2897, 5: 3.2897, 6: 2.72392, 7: 2.72392, 8: 2.72392, ,
internally used knots (9): 0: 3.55926, 1: 3.55926, 2: 3.55926, 3: 3.2897, 4: 3.2897, 5: 3.2897, 6: 2.72392, 7: 2.72392, 8: 2.72392, "
The internally used knots are set as required
Now let us grab the spline in
spline1.dxf and list its details with the following code executed in the Script Shell (
GE):
Code: Select all
var doc = EAction.getDocument();
var ids = doc.queryAllEntities(false, false, RS.EntitySpline);
var entity = doc.queryEntityDirect(ids[0]);
var spline = entity.castToShape();
spline.toString()
Code: Select all
RSpline(RShape(address: "0xd267268"), degree: 3, dirty: false, order: 4, closed: false, periodic: false, start point: "RVector(1.041568, 4.095543, 0.000000, 1)", end point: "RVector(0.968029, 4.095543, 0.000000, 1)", start tan: "RVector(0.000000, 0.000000, 0.000000, 1)", end tan: "RVector(0.000000, 0.000000, 0.000000, 1)", t_min: 2.72392, t_max: 3.55926,
controlPoints (7): 0: "RVector(1.041568, 4.095543, 0.000000, 1)", 1: "RVector(1.029296, 4.094821, 0.000000, 1)", 2: "RVector(1.008161, 4.095679, 0.000000, 1)", 3: "RVector(0.990142, 4.095463, 0.000000, 1)", 4: "RVector(0.981557, 4.095360, 0.000000, 1)", 5: "RVector(0.973876, 4.095199, 0.000000, 1)", 6: "RVector(0.968029, 4.095543, 0.000000, 1)", ,
weights (0): ,
fitPoints (0): ,
knots (9): 0: 2.72392, 1: 2.72392, 2: 2.72392, 3: 3.2897, 4: 3.2897, 5: 3.2897, 6: 3.55926, 7: 3.55926, 8: 3.55926, ,
internally used knots (9): 0: 2.72392, 1: 2.72392, 2: 2.72392, 3: 3.2897, 4: 3.2897, 5: 3.2897, 6: 3.55926, 7: 3.55926, 8: 3.55926,
Closing in on the issue ... Can you spot the difference apart from being reversed?
Besides that
dirty is true,
t_min and
t_max of our Spline shape are both zero.
Hence a Spline rendered from t=0 to t=0.
Hence a Null-entity ... With reference points and thus with selection markers.
Setting
TMin and
TMax is not an option.
The method
update() is already called for with setting the knots list.
The method
updateInternal() is not an option (Protected).
I found another method that calls
updateInternal() ... Including
var test = spline.getActualKnotVector(); after the knot list is set.
dirty is now false, actual knots are fine but
t_min and
t_max remain zero.
Wait a minute .... t min/max
... Your knots are listed from large to small

Reverse both the Control Point list and the Knot Vector list and all is fine.
All for the time being ....
I could not have solved this
WITHOUT THE DEBUGGER.
Then scripting under QCAD, support and much more ends.
And thank you very much.
This opens up routes for approximations of a hyperbola or an involute with splines.
If I ever want (and/or still can) update the gear generator exploiting a given modulus with splines as tooth profile.
A hyperbola is the line of equal distance between Arcs/Circles of different sizes, required to form a skeleton of an enclosed area.
A skeleton is the base for a Pocketing path by CAM.
Regards
CVH