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

Cutting a fused shape shows only edges #93

Open
bramvandooren opened this issue Jul 31, 2023 · 5 comments
Open

Cutting a fused shape shows only edges #93

bramvandooren opened this issue Jul 31, 2023 · 5 comments

Comments

@bramvandooren
Copy link

bramvandooren commented Jul 31, 2023

When trying the code below to cutout a fused circle with text it only show the edges of the fused shape instead of it being cut.

const main = (r) => {
       function center(drawing) {
            const boundingBox = drawing.boundingBox;
            drawing = drawing.translate(-boundingBox.center[0], -boundingBox.center[1]);

            return drawing;
        }

        let plate = drawRectangle(5, 5).cut(
            drawCircle(0.5)
                .fuse(center(drawText('test', { fontSize: 2 })).translate(0, 0.8).rotate(90))
        );

        return plate.sketchOnPlane('XY').extrude(0.2);
};
Screenshot 2023-07-31 165913

This also happens when only using a to be cutout when using this code:

const main = (r) => {
       function center(drawing) {
            const boundingBox = drawing.boundingBox;
            drawing = drawing.translate(-boundingBox.center[0], -boundingBox.center[1]);

            return drawing;
        }

        let text = drawText( 'text');
        text = text
            .stretch(1 / (text.boundingBox.width / 7.5), [0, 1], text.boundingBox.center)
            .stretch(1 / (text.boundingBox.height / 2), [1, 0], text.boundingBox.center);

        let plate = drawRectangle(10, 20).cut(
          center(text)
        );

        return plate.sketchOnPlane('XY').extrude(0.2);
};

Screenshot 2023-08-01 094442
@raydeleu
Copy link

raydeleu commented Oct 19, 2023

I suspected that the character "e" could be the culprit, but this seems not the case. A simple workaround is to extrude the shapes first before performing the cut.

const {draw, drawRectangle, drawCircle, drawText} = replicad

const main = (r) => {
       function center(drawing) {
            const boundingBox = drawing.boundingBox;
            drawing = drawing.translate(-boundingBox.center[0], -boundingBox.center[1]);

            return drawing;
        }

        let plate = drawRectangle(5, 5).sketchOnPlane("XY").extrude(0.2)
        let cutter = drawCircle(0.5).fuse(center(drawText('test', { fontSize: 2 })).translate(0, 0.8).rotate(90))
        cutter = cutter.sketchOnPlane("XY").extrude(1.0);
        plate = plate.cut(cutter)

        return plate;
};

image

@raydeleu
Copy link

Just doodling ... single characters work fine, but multiple characters fail. Perhaps a relation with an earlier issue #50 ?

image

const {draw, drawRectangle, drawCircle, drawText} = replicad

const main = (r) => {
       function center(drawing) {
            const boundingBox = drawing.boundingBox;
            drawing = drawing.translate(-boundingBox.center[0], -boundingBox.center[1]);

            return drawing;
        }
        let text = drawText( '0',{fontSize : 8}).translate([0,4]);
        let text2 = drawText( 'experiment',{fontSize : 8}).translate([-17,-4])    
        let plate = drawRectangle(60, 40).cut(text).cut(text2);

        return plate.sketchOnPlane('XY').extrude(0.2);
};

@paulftw
Copy link
Contributor

paulftw commented Oct 24, 2023

Cutting 3d shapes is performed by calling OCCT methods, 2d boolean ops are implemented in JS (based on my limited experience with replicad codebase and bug reports).
So cutting after extrusion will have different results (often better, because that code is used in many other projects).

@bramvandooren
Copy link
Author

Thank you for your response. I've explored the option of cutting after extrusion for this particular scenario, and while it may not be the optimal solution for my project, it serves as a viable workaround for the time being. Your assistance is greatly appreciated.

@sgenoud
Copy link
Owner

sgenoud commented Dec 20, 2023

I confirm the whole issue - and I have been working on a better solution for 2D booleans (which can be faster) - but nothing that I would recommend yet unfortunately.

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

4 participants