Closed nagbzh closed 1 year ago
Hi,
Actually weights are supported, see example below:
import { DxfWriter, point3d } from "@tarikjabiri/dxf"
const dxf = new DxfWriter()
const controlPoints = [
point3d(0, 0),
point3d(10, 10),
point3d(20, 10),
point3d(30, 20)
]
// You can define an array of weights
const weights = [] // Here add weights.
dxf.addSpline({
controlPoints,
weights
})
// Or
dxf.addSpline({
controlPoints,
weights: [] // Here add weights.
})
// Or
const spline = dxf.addSpline({
controlPoints
})
spline.weights = []
// Or
spline.weights.push(....)
These all properties you can set (Spline):
export type SplineArgs_t = {
controlPoints: vec3_t[];
fitPoints?: vec3_t[];
degreeCurve?: number;
flags?: SplineFlags;
knots?: number[];
weights?: number[];
};
I hope this can help you.
Regards
It seems to me that the generated dxf is not correct.
The example below generates the dxf in red while the expected result is the dxf in green.
No lines with the group code 41 are generated in the dxf.
Sorry for my English but I don't speak this language.
Regards.
import {DxfWriter, point3d} from "@tarikjabiri/dxf"
const dxf = new DxfWriter()
const points = [
point3d(-100, 0, 0),
point3d(-50, 50, 0),
point3d(50, -50, 0),
point3d(100, 0, 0)
];
const knots = [0, 0, 0, 1, 2, 2, 2]
const weights = [1, 10, 10, 1]
dxf.addSpline({
controlPoints: points,
degreeCurve: 2,
knots: knots,
weights: weights
})
Yeah the weights were not serialized, update to v2.5.5
.
In that case try to set fitPoints
property:
const dxf = new DxfWriter();
const points = [
point3d(-100, 0, 0),
point3d(-50, 50, 0),
point3d(50, -50, 0),
point3d(100, 0, 0)
];
const knots = [0, 0, 0, 1, 2, 2, 2]
const weights = [1, 10, 10, 1]
dxf.addSpline({
controlPoints: points,
fitPoints: points, // This will make sure the spline pass over all points
degreeCurve: 2,
knots: knots,
weights: weights
})
The v2.5.5
still not published please wait I will publish it.
v2.5.5 published.
Great, thanks for the update.
Hello,
Thank you for all the work done so far.
Currently splines with weights are not managed. It's a pity because we can't draw all the cases. Do you plan to implement this feature?
Thanks.