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.

Featurescript Boolean of Booleans not working

Pierre_GarboPierre_Garbo Member Posts: 4

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

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,829
    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

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,829
    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_GarboPierre_Garbo Member Posts: 4

    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

Sign In or Register to comment.