@opBoolean: BOOLEAN_SAME_INPUT error message

CAD_SSP
CAD_SSP Member Posts: 45 ✭✭
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:
<div>&nbsp; &nbsp; // Create Hole cylinder geometry

</div><div>&nbsp; &nbsp; fCylinder(context, id + THstr, { "bottomCenter" : THBot1, "topCenter" : THTop1, "radius" : TH_RADIUS&nbsp; });</div><div>&nbsp; &nbsp;&nbsp;

</div><div>&nbsp; &nbsp; // Subtract Hole Geometry from all other bodies to create holes.

</div><div>&nbsp; &nbsp; opBoolean(context, id + THbooleanstr, { tools : qCreatedBy(id + THstr, EntityType.BODY), targets : everythingelse,&nbsp; operationType : BooleanOperationType.SUBTRACTION });</div><div>&nbsp; &nbsp;&nbsp;

    //Update ID Strings

</div><div>&nbsp; &nbsp; THstr ~= 1;

</div><div>&nbsp; &nbsp; THbooleanstr ~= 1;</div><div>&nbsp; &nbsp;&nbsp;

</div><div>&nbsp; &nbsp; // Create 2nd Hole cylinder geometry

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

</div><div>&nbsp; &nbsp; // Subtract Hole Geometry from all other bodies to create holes.

</div><div>&nbsp; &nbsp; opBoolean(context, id + THbooleanstr, { tools : qCreatedBy(id + THstr, EntityType.BODY), targets : everythingelse, operationType : BooleanOperationType.SUBTRACTION });</div>
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_SSP
    CAD_SSP Member Posts: 45 ✭✭
    @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:
    <div>&nbsp; &nbsp; // Create 2nd Hole cylinder geometry
        fCylinder(context, id + THstr, { "bottomCenter" : THBot2, "topCenter" : THTop2, "radius" : TH_RADIUS });
    </div><div>
        //Update everythingelse
        everythingelse = qSubtraction(everythingelse, qCreatedBy(id + THstr, EntityType.BODY));
    </div><div>&nbsp; &nbsp;&nbsp;
    </div><div>&nbsp; &nbsp; // 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 });
    </div>

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

    <div>    everythingelse = qSubtraction(everythingelse, qUnion([qCreatedBy(id + THstr, EntityType.BODY),qCreatedBy(id + THstr2, EntityType.BODY)]));
    
    <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">    // Create Hole cylinder geometry
    </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">    fCylinder(context, id + THstr, {
    </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">&nbsp;   &nbsp; "bottomCenter" : THBot1,
    </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">&nbsp;  &nbsp; "topCenter" : THTop1,
    </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">&nbsp;   &nbsp; "radius" : TH_RADIUS
    </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">    });</span></div><div><span style="background-color: transparent; color: inherit; font-size: inherit;">
    
    <font face="Flama, sans-serif">    </font></span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">// Create 2nd Hole cylinder geometry
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; fCylinder(context, id + THstr2, {
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; "bottomCenter" : THBot2,
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; "topCenter" : THTop2,
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; "radius" : TH_RADIUS
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; });
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">
        // Subtract Hole Geometry from all other bodies to create holes.
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; opBoolean(context, id + THbooleanstr, {
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; tools : qUnion([qCreatedBy(id + THstr, EntityType.BODY),qCreatedBy(id + THstr2, EntityType.BODY)]),
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; targets : everythingelse,
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; operationType : BooleanOperationType.SUBTRACTION
    </span><span style="background-color: transparent; color: inherit; font-family: Flama, sans-serif; font-size: inherit;">&nbsp; &nbsp; });</span></div>
  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    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!

    Senior Director, Technical Services, EMEA