CascadeStudio icon indicating copy to clipboard operation
CascadeStudio copied to clipboard

[Fixed by Myself] Sketch can not End more than once to draw a face.

Open Richard20230331 opened this issue 1 year ago • 0 comments

So the problem is that you can draw a face like this:

const a = new Sketch([0, 0], 0); a.Start([0, 0]).LineTo([-10, 0]).LineTo([0, 20]).LineTo([0, 0]).End(); a.Face();

But you can not draw a face like this:

a.Start([0, 0]).LineTo([-10, 0]).LineTo([0, 20]).End(); a.Start([0, 20]).LineTo([0, 0]).End(); a.Face();

It seems that there is a problem in Library.js, SketchInstance.End() method:

faceBuilder = new oc.BRepBuilderAPI_MakeFace(this.wires[0]); for (let w = 1; w < this.wires.length; w++){ faceBuilder.Add(this.wires[w]); }

It seems wrong to add wires to MakeFace, cuz the render result is always wrong. I changed the code like this:

let myWire = new oc.BRepBuilderAPI_MakeWire(); for (let w = 0; w < this.wires.length; w++){ myWire.Add(this.wires[w]); } faceBuilder = new oc.BRepBuilderAPI_MakeFace(myWire.Wire());

Please let me know if this makes sense or not, I just did it without too much dive with the occ logic. Now that you can try the code and get the right render result.

Richard20230331 avatar Sep 25 '24 07:09 Richard20230331