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.

Options

How do I reference a body after a BooleanOperationType.SUBTRACT_COMPLEMENT operation?

joshua_babcockjoshua_babcock Member Posts: 4 ✭✭
It seems like the first time I perform a boolean op on something, I loose the ability to query it anymore. I thought this was what qCreatedBy() was for, but I can't seem to get that working either. It seems to return either nothing or, in the case of a union, some new points and edges that belong to the body I'm interested in.
In the included version, I can get the behavior I want, except that when I use the subtract complement functionality, I can't get the result to be applied to the original object, it ends up in a new object. Without that extra operation, it just modifies the original body, which is what I want. The problems start around line 95. Specifically, I don't understand why the debug statements at 109 and 110 come back empty.

See: https://cad.onshape.com/documents/811a3cd3b3c20b703ec44a95/v/a3517234f59dc4300c978185/e/a9198342824bf38f7fdfd502
Tagged:

Best Answer

  • Options
    Alex_KempenAlex_Kempen Member Posts: 244 EDU
    edited May 2021 Answer ✓
    Okay, if I'm understanding your code correctly, you're making a copy of the result of extruding your feature, subtracting the complement of that result from the original feature, then merging that back into your original part.
    Adressing your issue directly, the first thing worth noting is that qCreatedBy won't work on a subtract complement boolean feature since the boolean doesn't actually create anything, only modify existing geometry (qCreatedBy will, however, work with boolean types like boolean union).

    The second part of your question revolves around the loss of the target. As you noticed, the query for your originalObj works fine before booleaning, but not after. This is because the opBoolean subtract complement feature is a subfeature which changes originalObj in such a way that the original query no longer works. Fortunately, this can be easily handled by using startTracking to create a tracking query before booleaning. The query created by startTracking should then resolve to originalObj as expected, even after booleaning.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



Answers

  • Options
    Alex_KempenAlex_Kempen Member Posts: 244 EDU
    edited May 2021 Answer ✓
    Okay, if I'm understanding your code correctly, you're making a copy of the result of extruding your feature, subtracting the complement of that result from the original feature, then merging that back into your original part.
    Adressing your issue directly, the first thing worth noting is that qCreatedBy won't work on a subtract complement boolean feature since the boolean doesn't actually create anything, only modify existing geometry (qCreatedBy will, however, work with boolean types like boolean union).

    The second part of your question revolves around the loss of the target. As you noticed, the query for your originalObj works fine before booleaning, but not after. This is because the opBoolean subtract complement feature is a subfeature which changes originalObj in such a way that the original query no longer works. Fortunately, this can be easily handled by using startTracking to create a tracking query before booleaning. The query created by startTracking should then resolve to originalObj as expected, even after booleaning.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • Options
    joshua_babcockjoshua_babcock Member Posts: 4 ✭✭
    Thanks, I had forgotten that tracking queries are a thing.
Sign In or Register to comment.