Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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 fails with invalid input
brad_phelan
Member Posts: 89 ✭✭
I'm developing my autoRib feature at
https://cad.onshape.com/documents/83f268820b92e08f4f30db06/w/ec7ac3c9e66d4c5dc475d388/e/aadea257f248d95c6631d7d5
The cylinder is the original part and the rectangular box is a solid generated half way through the script. I wish to opBoolean::Intersect these two. However opBoolean fails with INVALID_INPUT and I am mystified as to why.
I have tried to make the code robust by ensuring only solids go to the opBoolean operation.
https://cad.onshape.com/documents/83f268820b92e08f4f30db06/w/ec7ac3c9e66d4c5dc475d388/e/aadea257f248d95c6631d7d5
The cylinder is the original part and the rectangular box is a solid generated half way through the script. I wish to opBoolean::Intersect these two. However opBoolean fails with INVALID_INPUT and I am mystified as to why.
I have tried to make the code robust by ensuring only solids go to the opBoolean operation.
var qr0 = qBodyType(qCreatedBy(id, EntityType.BODY), BodyType.SOLID);
var qr1 = qBodyType(entities, BodyType.SOLID);
var qq = qUnion([qr0,qr1]);
// This outputs 1 Solid and 1 Face (weird)
debug(context,qq);
opBoolean(context, id + "boolean1", {
"tools" : qq ,
"operationType" : BooleanOperationType.INTERSECTION
});
however debug outputs
Query resolves to 1 bodies, 1 faces
If I do an opDelete on qq then the cylinder and the box are removed.
What could be going wrong.
Source code for opRibFromPlane is at
https://cad.onshape.com/documents/83f268820b92e08f4f30db06/w/ec7ac3c9e66d4c5dc475d388/e/e85455e9a0f5ab76faab2043
however debug outputs
Query resolves to 1 bodies, 1 faces
If I do an opDelete on qq then the cylinder and the box are removed.
What could be going wrong.
Source code for opRibFromPlane is at
https://cad.onshape.com/documents/83f268820b92e08f4f30db06/w/ec7ac3c9e66d4c5dc475d388/e/e85455e9a0f5ab76faab2043
0
Comments
possibly you need: var qr0 = qBodyType(qCreatedBy(id + "extrude1", EntityType.BODY), BodyType.SOLID);
I had passed in a face to the function ( as selected in the feature ) instead of a part.
However why does
var qr1 = qBodyType(entities, BodyType.SOLID);
still return a result in the query.
https://cad.onshape.com/documents/ce8000dae12df34ec634041e/w/7a822b306bad8b1d8c55b7b9/e/e325cc4f8612678591a39cf4
qBodyType doesn't do what you're expecting it to do. qBodyType(query, BodyType.SOLID) will query for all entities of 'query' that are either a) solid bodies or b) belong to solid bodies. So, as long as your selected face belonged to a solid body it would bass the body type test.
I think the query you're looking for is:
or
if you want to be extra careful about only getting solid bodies.
Also, just as a FeatureScript note, your utility functions (fPatternPlanes, fBoundingPlanes, opRibFromPlane, etc) don't need to be 'export'ed unless you want to use them in another FeatureScript file, and don't need an 'annotation {}' at all. You can use 'print(...)' or 'println(...)' instead of 'debug(...)' if you want to print strings or see the content of variables that aren't 'Query's.
Edit: I would also try to avoid using dummyQuery. It looks like what you're trying to do can be accomplished with 'qCreatedBy(...)'
@Jake_Rosenfeld thanks for those tips. I'll fold the advice in.