Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Having issues with FeatureScrip Extrude Remove
mario_acosta380
Member Posts: 6 ✭
I don't know if my previous question went by. I will ask it again.
So, I am trying to do a custom-made feature script. The code has no errors, though instead of removing it, it is adding material. Please see my code:
So, I am trying to do a custom-made feature script. The code has no errors, though instead of removing it, it is adding material. Please see my code:
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);
});
0
Answers
Note: with the latest version of onshape/std/common.fs, you have to import the extrude feature separately.
Usually, when making a custom feature, you don't want all of the original features functionality. So opExtrude is recommended. Here is how you could do it with opExtrude:
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴