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.

Why Feature Script opExtrude REMOVE not working and making a NEW part?

shimon_shmulmanshimon_shmulman Member Posts: 5
edited June 2020 in Community Support

Hello,

I am trying to shorten the cylinder by opExtrude with the following code:


FeatureScript 1301;
import(path : "onshape/std/geometry.fs", version : "1301.0");

annotation { "Feature Type Name" : "Face 03" }
export const face03 = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
        definition.prop_face is Query;
    }
    {
        opExtrude(context, id + "extrude1", {                   
                    "operationType" : NewBodyOperationType.REMOVE,                    
                    "entities" : definition.prop_face,
                    "direction" : evPlane(context, { "face" : definition.prop_face }).normal * -1,
                    "endBound" : BoundingType.BLIND,
                    "endDepth" : 200 * millimeter
                });
    });

For some reason NewBodyOperationType.REMOVE tag is not working and a new part is generated.
Please help, what can be done?

Shimon

Best Answer

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    operationType is not a parameter for opExtrude. You will need to do an opBoolean to remove the body created by your opExtrude. This is the preferred method. 

    The extrude function includes opBoolean and so operationType is valid for that. 




    Senior Director, Technical Services, EMEAI
  • shimon_shmulmanshimon_shmulman Member Posts: 5
    Neil,

    Thank you for your answer. I tried to use extrude, but it has no effect on the part.
    I must be doing something wrong.



    FeatureScript 1301;
    import(path : "onshape/std/geometry.fs", version : "1301.0");

    annotation { "Feature Type Name" : "Face 03" }
    export const face03 = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
            definition.prop_face is Query;
        }
        {
            extrude(context, id + "extrude1", {
                        "entities" : definition.prop_face,
                        "direction" : evPlane(context, { "face" : definition.prop_face }).normal * -1,
                        "operationType" : NewBodyOperationType.REMOVE,
                        "defaultScope" : true,
                        "endBound" : BoundingType.BLIND,
                        "depth" : 200 * millimeter
                    });

        });
  • shimon_shmulmanshimon_shmulman Member Posts: 5
    Neil,

    Thanks for your help!

    Shimon
  • shimon_shmulmanshimon_shmulman Member Posts: 5
    edited June 2020
    Just want to share with the community the working code for this issue:

    <b>FeatureScript 1301;</b><br><b>import(path : "onshape/std/geometry.fs", version : "1301.0");</b><br><b>annotation { "Feature Type Name" : "Face 03" }</b><br><b>export const face03 = defineFeature(function(context is Context, id is Id, definition is map)</b><br><b>&nbsp; &nbsp; precondition</b><br><b>&nbsp; &nbsp; {</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; definition.prop_face is Query;</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; annotation { "Name" : "Solid", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; definition.prop_body is Query;</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</b><br><b>&nbsp; &nbsp; }</b><br><b>&nbsp; &nbsp; {</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; opExtrude(context, id + "extrude1", {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "operationType" : NewBodyOperationType.REMOVE,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "entities" : definition.prop_face,</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "direction" : evPlane(context, { "face" : definition.prop_face }).normal * -1,</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "endBound" : BoundingType.BLIND,</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "endDepth" : 200 * millimeter</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; opBoolean(context, id + "boolean1", {</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "tools" : qBodyType(qCreatedBy(id + "extrude1", EntityType.BODY), BodyType.SOLID),</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "targets" : definition.prop_body,</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "operationType" : BooleanOperationType.SUBTRACTION</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp; });</b><br><b>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</b><br><b>&nbsp; &nbsp; });</b>

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    FYI @shimon_shmulman

    You can hit the "code" formatting button:

    And then paste code from your feature studio into the yellow box that shows up.

    example

    Jake Rosenfeld - Modeling Team
  • shimon_shmulmanshimon_shmulman Member Posts: 5
    Jake,

    I did hit the code format, but then only the first line was visible.
    Is it supposed to work this way?
    In addition, I still do not understand what was wrong with my extrude function.

    Shimon
Sign In or Register to comment.