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.
Deleting Multiple Sketches with one opDeleteBodies???
Stormi_Backus
Member Posts: 49 ✭
I am working on a featurescript for taper lock bushings that will have something like 50 sketches/fitSplines after I work in all available sizes/hole patterns.
Individually deleting bodies is helpful during custom feature generation, but, imo, makes the script unnecessarily long once finalized.
Is there a way to delete all sketch bodies within a featurescript at the end rather than having multiple instances of opDeleteBodies throughout? I can't see a way to work around the fact that all of the sketches have a different id. I guess i'm looking for a sort of 'qAllSketchEntities' if that exists...
I found an old forum post that involves accomplishing the same task for imported part studios but I am not sure how that solution would translate to my scenario: https://forum.onshape.com/discussion/6130/featurescript-query-delete-all-sketches
Thanks in advance for any guidance!
Individually deleting bodies is helpful during custom feature generation, but, imo, makes the script unnecessarily long once finalized.
Is there a way to delete all sketch bodies within a featurescript at the end rather than having multiple instances of opDeleteBodies throughout? I can't see a way to work around the fact that all of the sketches have a different id. I guess i'm looking for a sort of 'qAllSketchEntities' if that exists...
I found an old forum post that involves accomplishing the same task for imported part studios but I am not sure how that solution would translate to my scenario: https://forum.onshape.com/discussion/6130/featurescript-query-delete-all-sketches
Thanks in advance for any guidance!
Tagged:
0
Best Answer
-
NeilCooke Moderator, Onshape Employees Posts: 5,714Repeating opDeleteBodies is expensive, so avoid if possible. A common way is to create an array and add bodies to delete as you go along, then call opDeleteBodies with qUnion(array). Not tried it, but I suspect this will work better:
opDeleteBodies(context, id + "deleteSketches", { "entities" : qSketchFilter(qCreatedBy(id), SketchObject.YES) });
Senior Director, Technical Services, EMEAI0
Answers