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.

Get remaining part after opBoolean union

jeff_day734jeff_day734 Member Posts: 9
edited September 4 in FeatureScript

This seems like it should be trivial, but I'm stumped: When I perform an opBoolean to merge a set of parts together into a single part, I can't figure out how to directly query the resulting part. As a work around, I use qNthElement to extract the first part out of the tools query prior to executing opBoolean, as that part is the resulting part. This works, but it seems very hacky. Any better ideas?

Here's a code excerpt demonstrating what I'm asking:

qParts = qUnion(qParts1, qParts2);

// Get the first element from qParts, as it will be the part into which opBoolean merges all the other parts
qfinalPart = qNthElement(qBaseParts, 0);
        
opBoolean(context, id + "boolean1", {
   "tools" : qBaseParts,
   "operationType" : BooleanOperationType.UNION
});

setProperty(context, {
    "entities" : qFinalPart,
    "propertyType" : PropertyType.NAME,
    "value" : "Final Part"
  });

In short: How do I determine qFinalPart from the opBoolean operation rather than having to infer it in advance using qNthElement?

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,690

    For Union it is always the first part, so you could just use qParts1 ?

    Senior Director, Technical Services, EMEAI
  • jeff_day734jeff_day734 Member Posts: 9

    Ya, that's a little syntactically easier. I guess I'm surprised that you can't get the unified part from opBoolean itself.

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,690

    If the first part was created by an extrude I usually use qCreatedBy(id + "extrude", EntityType.BODY)

    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.