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.

opBoolean UNIONs

robert_carpenter114robert_carpenter114 Member Posts: 8 ✭✭
 For anyone having difficulties with opBoolean unions, I discovered that adding 
"targetsAndToolsNeedGrouping" : true to the parameters list
caused the operation to be performed successfully. 

opBoolean(context, getUID(id, "boolean", 2), {
                       "tools" : qCreatedBy(getUID(id, "extrude", 2), EntityType.BODY),
                       "targets" : partToADDto,
                    "operationType" : BooleanOperationType.UNION,
                    "targetsAndToolsNeedGrouping" : true
                    
                });

Comments

  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭
    @robert_carpenter114
    It is because, when you don't have "targetsAndToolsNeedGrouping" : true, it only uses the tools, not the targets. It is link the normal Boolean feature
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited April 2018
    To elaborate a bit on what @mbartlett21 said:
    The preferred way to do a simple boolean union is to put all the bodies to merge into the "tools" field. You can do this by combining multiple queries with qUnion.
    <div>opBoolean(context, id + "boolean1", {
            "tools" : qUnion([
                    firstEntities,
                    secondEntities
                ]),
            "operationType" : BooleanOperationType.UNION
    });<br></div>
    "targetsAndToolsNeedGrouping" provides a more complex behavior, which can be useful for when a single union is grouping multiple sets of disjoint bodies. For a simple union of two parts, the above code is sufficient (and will more accurately report when the union did not have any effect).
  • robert_carpenter114robert_carpenter114 Member Posts: 8 ✭✭
    Oh Okay.  Thanks for pointing this out Kevin.   My one tiny criticism of the Featurescript project is its apparent lack of a 'cookbook' type of guide.   The idea of the cookbook is to compile a whole bunch of little examples of the sort where you say 'now suppose you want to do this, then here is a little example code snippet that does it.'   I think that's the   way most people learn something.
  • Cache_River_MillCache_River_Mill Member Posts: 225 PRO
    To elaborate a bit on what @mbartlett21 said:
    The preferred way to do a simple boolean union is to put all the bodies to merge into the "tools" field. You can do this by combining multiple queries with qUnion.
    <div>opBoolean(context, id + "boolean1", {
            "tools" : qUnion([
                    firstEntities,
                    secondEntities
                ]),
            "operationType" : BooleanOperationType.UNION
    });<br></div>
    "targetsAndToolsNeedGrouping" provides a more complex behavior, which can be useful for when a single union is grouping multiple sets of disjoint bodies. For a simple union of two parts, the above code is sufficient (and will more accurately report when the union did not have any effect).
    Thank you, this helped.
Sign In or Register to comment.