Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape, CAD, maker project and design.

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.

Extrude separate adjacent shapes

emory_krallemory_krall Member Posts: 4 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. 

Best Answer

Answers

  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 694
  • owen_sparksowen_sparks Member, Developers, Configurations EVP Posts: 916 PRO
    edited September 12
    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.
    Production Engineer
    HWM-Water Ltd
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 694
    @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 - Onshape
  • ilya_baranilya_baran Onshape Employees, Developers, Configurations EVP Posts: 698
    @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 \ Director of FeatureScript \ Onshape Inc
  • Jake_RosenfeldJake_Rosenfeld Onshape Employees, Developers Posts: 404
    Accepted Answer
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 694
    ^^^ @Jake_Rosenfeld - nice! But how does it work? :)
    Philip Thomas - Onshape
  • Jake_RosenfeldJake_Rosenfeld Onshape Employees, Developers Posts: 404
    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_Operator
    Jake Rosenfeld - Modeling Team
  • philip_thomasphilip_thomas Member, Onshape Employees, Developers Posts: 694
    ^^^Nice! :)
    Philip Thomas - Onshape
  • owen_sparksowen_sparks Member, Developers, Configurations EVP Posts: 916 PRO
    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.
    Production Engineer
    HWM-Water Ltd
  • emory_krallemory_krall Member Posts: 4 PRO
    Thanks @Jake_Rosenfeld!!! This is perfect. It even extrudes up to a face which is how we would generally need to use it. Fantastic!
  • Jake_RosenfeldJake_Rosenfeld Onshape Employees, Developers Posts: 404
     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 Team
Sign In or Register to comment.