Featurescript Boolean of Booleans not working

Pierre_Garbo
Pierre_Garbo Member Posts: 4 EDU

Hi!

I am having trouble with booleans in featurescript when using the result of a boolean as a tool for another boolean.

I have attached a simple example to explain my problem better. In this case, I generate 3 intersecting cylinders: I want to do a Boolean to combine the first two and then another Boolean to intersect the resulting part from the first Boolean operation with the third cylinder.

I know I could do everything in one step, but this is just to show the issue I am facing.

I traced the error back to the fact that if I do println(evaluateQuery(context, boolResult)), where boolResult is the result of the first Boolean operation, I get "[]" in the featurescript notice.

I tried everything I found on the internet but I wasn't able to solve this.

https://cad.onshape.com/documents/1fca0a6bfe3a825a41a4717b/w/56d1b8e593cd029952aa15a3/e/7be6f039cf74e2d1493bc614

Can anyone help me with this, please?

Cheers,

Pierre

Best Answer

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,123 image
    Answer ✓
    var boolResult = qCreatedBy(id + "cylinder1", EntityType.BODY);
    

    The result of a boolean has the same id as the first body in the boolean operation.

    Senior Director, Technical Services, EMEA

Answers

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,123 image
    Answer ✓
    var boolResult = qCreatedBy(id + "cylinder1", EntityType.BODY);
    

    The result of a boolean has the same id as the first body in the boolean operation.

    Senior Director, Technical Services, EMEA
  • Pierre_Garbo
    Pierre_Garbo Member Posts: 4 EDU

    Thanks Neil,

    I missed that piece of logic to understand what I was doing wrong.

    Also, I think it is worth mentioning another similar discussion that I just found and that provides a good workaround (of which now I understand the logic): query bodies created by boolean? — Onshape

    Cheers