Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Richard20230331 opened this issue Sep 25, 2024 · 0 comments
Open

Comments

@Richard20230331
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant