Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Please help with the script to Remove Extrude: NewBodyOperationType.REMOVE,

mario_acosta380mario_acosta380 Member Posts: 6
Hello. Thank you for the help. 

I am trying to do a custom script that removes material by extruding it. 

I have tried multiple ways, though the material is not being removed, it is just being added: 

FeatureScript 2411;
// Import the FeatureScript standard library
import(path : "onshape/std/common.fs", version : "2411.0");

// Define a custom feature
annotation { "Feature Type Name" : "Custom Remove Extrude", "Editing Logic" : "FeatureScript" }
export const customRemoveExtrude = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        // Input for selecting a sketch
        annotation { "Name" : "Sketch", "Filter" : EntityType.FACE }
        definition.sketch is Query;
    }
    {
        // Define the constant extrusion depth
        // const extrusionDepth = 7 * millimeter;

        // Logic for removing the extruded material
        var extrudeDefinition = {
            "entities" : definition.sketch,
            "direction" : evOwnerSketchPlane(context, { "entity" : definition.sketch }).normal,
            "endBound" : BoundingType.THROUGH_ALL,
            "operationType" : NewBodyOperationType.REMOVE,
            // "endDepth" : extrusionDepth,
        };

        // Perform the remove extrusion operation
        opExtrude(context, id + "removeExtrude", extrudeDefinition);
    });

Answers

Sign In or Register to comment.