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.
Extrude separate adjacent shapes
emory_krall
Member Posts: 15 PRO
Does anyone know of a way to extrude two or more adjacent sketch outlines as separate objects? I often need to do this and wind up making several separate extrude features, but it would be much quicker and simpler if there was a featurescript or something that would do it in one operation.
Tagged:
2
Best Answer
-
Jake Rosenfeld - Modeling Team5
Answers
-
You mean like this?


https://cad.onshape.com/documents/d227788a2cb87e323b137a39/w/75adf83fcc68513e42d65e6e/e/937116e9df75d574d6e8cc04
Philip Thomas - Onshape0 -
I believe the op means regions that touch each other. In the past we've floated the concept of extruding the carcass of a draw for example. 4 individual sides but currently we'd need two extrude features else OS will merge the sides together.
Cheers, Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd0 -
@owen_sparks - Yes - if two profiles touch or overlap today, they would be extruded as a single body. Ideas have been floated to introduce the concept of 'bodies' in sketching (allowing things like boolean operations), but the conversations have (so far) ended with "the limited benefits are outweighed by the large number of new concepts and features required". If you have any ideas on how to do this as simply as possible, we are all ears!
Philip Thomas - Onshape1 -
@philip_thomas
I think the op is just asking for a custom feature that will extrude each face of the input as a separate body. Unfortunately I don't have time to hack this up at the moment...Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
Jake Rosenfeld - Modeling Team5
-
-
It does exactly what @emory_krall has already been doing! It just calls extrude separately for each selected profile (so no guarantees on performance).
var definitionForOp = definition; var count = 0; const relevantEntityField = definition.bodyType == ToolBodyType.SOLID ? "entities" : "surfaceEntities"; for (var entity in evaluateQuery(context, definition[relevantEntityField])) { definitionForOp[relevantEntityField] = entity; // keep original id for first entity so that manipulators work var idForOp = (count == 0) ? id : (id + count); count += 1; extrude(context, idForOp, definitionForOp); }
Basically make the user supply the same definition as extrude takes, then apply to each entity separately (with some id finagling).
Some semantic sugar also:
'definition.entities' is the same as 'definition["entities"]'
ternary operator (var a = condition ? this : that): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_OperatorJake Rosenfeld - Modeling Team3 -
^^^Nice!
Philip Thomas - Onshape0 -
Works perfectly, make it native please

Thanks again @Jake_Rosenfeld
For 10 points name another CAD company that will write you two new free features with 24 hours of asking...
Cheers,
Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd2 -
Thanks @Jake_Rosenfeld!!! This is perfect. It even extrudes up to a face which is how we would generally need to use it. Fantastic!0
-
Hi All!
Thanks for the kind words, glad I could help! I've pushed a V2 with a very small fix that makes references to the created bodies more stable.
There's also some weirdness with the "entities" box (you may notice all of your selected faces collapsing into one selection called "Missing of sketch X"). This should not be a huge problem as selections/deselections should act as usual in the graphics are. We are investigating this as it seems like a systematic issue, hopefully it doesn't cause too much inconvenience.Jake Rosenfeld - Modeling Team0 -
I had that same problem a while back, until I realised it was caused by the Id.Jake_Rosenfeld said:There's also some weirdness with the "entities" box (you may notice all of your selected faces collapsing into one selection called "Missing of sketch X"). This should not be a huge problem as selections/deselections should act as usual in the graphics are. We are investigating this as it seems like a systematic issue, hopefully it doesn't cause too much inconvenience.
0 -
@mbartlett21
Yup, it's caused by the Id, but if I don't piggyback off the Id in that way, I'd have to do extra work to have the manipulators (or just not have them at all).
Jake Rosenfeld - Modeling Team0 -
Thank you @Jake_Rosenfeld! I'm using OnShape to make a stained glass window pattern (of all things) but as you might imagine, your script just saved me a ton of time!
1 -
-
exactly what I was looking for today… thanks @Jake_Rosenfeld
0







