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.

@opBoolean: BOOLEAN_SAME_INPUT error message

CAD_SSPCAD_SSP Member Posts: 45 PRO
edited January 2018 in FeatureScript
I am trying to create 2 holes in the same body using an adaption of the featurescript from "Dowel and Minifix", I can create and subtract the first hole and create the cylinder for the second hole but when I try to subtract that I get the error "@opBoolean: BOOLEAN_SAME_INPUT".

My code is as follows:
    // Create Hole cylinder geometry

    fCylinder(context, id + THstr, { "bottomCenter" : THBot1, "topCenter" : THTop1, "radius" : TH_RADIUS  });    

    // Subtract Hole Geometry from all other bodies to create holes.

    opBoolean(context, id + THbooleanstr, { tools : qCreatedBy(id + THstr, EntityType.BODY), targets : everythingelse,  operationType : BooleanOperationType.SUBTRACTION });    

    //Update ID Strings

    THstr ~= 1;

    THbooleanstr ~= 1;    

    // Create 2nd Hole cylinder geometry

    fCylinder(context, id + THstr, { "bottomCenter" : THBot2, "topCenter" : THTop2, "radius" : TH_RADIUS });
    //Works fine up to this point

    // Subtract Hole Geometry from all other bodies to create holes.

    opBoolean(context, id + THbooleanstr, { tools : qCreatedBy(id + THstr, EntityType.BODY), targets : everythingelse, operationType : BooleanOperationType.SUBTRACTION });
I have tried googling the error but no results.

If there is a way to subtract multiple bodies that would be even more useful!

Thanks in advance for any help.

Best Answer

Answers

  • CAD_SSPCAD_SSP Member Posts: 45 PRO
    @NeilCooke found the error (soon as I clicked "Ask Question" I had a flash of inspiration but couldn't cancel the post)

    "everythingelse" is created by subtracting a created hole cylinder from literally everything else so I had to update that to be the new hole cylinder I had just created and it worked fine.

    added...
        everythingelse = qSubtraction(everythingelse, qCreatedBy(id + THstr, EntityType.BODY));

    as follows:
        // Create 2nd Hole cylinder geometry
        fCylinder(context, id + THstr, { "bottomCenter" : THBot2, "topCenter" : THTop2, "radius" : TH_RADIUS });
    
        //Update everythingelse
        everythingelse = qSubtraction(everythingelse, qCreatedBy(id + THstr, EntityType.BODY));
        
        // Subtract Hole Geometry from all other bodies to create holes.
        opBoolean(context, id + THbooleanstr, { tools : qCreatedBy(id + THstr, EntityType.BODY), targets : everythingelse, operationType : BooleanOperationType.SUBTRACTION });
    

    Your qUnion suggestion is a good one so will try that.
  • CAD_SSPCAD_SSP Member Posts: 45 PRO
    Final solution in case anyone else has the same query:

        everythingelse = qSubtraction(everythingelse, qUnion([qCreatedBy(id + THstr, EntityType.BODY),qCreatedBy(id + THstr2, EntityType.BODY)]));
    
        // Create Hole cylinder geometry
        fCylinder(context, id + THstr, {
          "bottomCenter" : THBot1,
         "topCenter" : THTop1,
          "radius" : TH_RADIUS
        });
    
    
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 3,254
    edited January 2018
    @keith_marsh looks great, although your first statement will do nothing since id + THstr and id + THstr2 do not exist yet

    EDIT: correction - your code is fine since your first statement is just constructing the query not executing it (which is done in opBoolean). Sorry!

Sign In or Register to comment.