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.

opExtrude UP_TO_FACE Issue

aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
Hi there, when I opExtrude as per below if the regionToExtrude is within the boundaries of the bottomface, it works ok, but if the regionToExtrude is outside the boundaries of the bottomface it doesnt work, is this expected behavior?  

opExtrude(context, id + "extrude1",
       { "entities" : regionToExtrude, 
        "direction" : zDirection *-1,
        "endBound" : BoundingType.UP_TO_FACE,   
        "endBoundEntity" : qNthElement(bottomface, 0),
        "operationType" : NewBodyOperationType.NEW,
        "defaultScope" : true
    });
Tagged:

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,310
    Yes it is. If in doubt, try to replicate your use case using the regular modelling tools. 
    Senior Director, Technical Services, EMEAI
  • aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
    Thanks Neil, so would I need to create a plane on the bottomface, then set endBoundEntity to that plane?
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,310
    Is bottomface planar? If so, that would work. If bottomface is parallel to your sketch plane, measure the distance and use blind. 
    Senior Director, Technical Services, EMEAI
  • aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
    Thanks Neil, I will go with measuring the distance and blind
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    @aaron_skidmore

    UP_TO_FACE is a deprecated option.  Please use UP_TO_SURFACE instead, which will expand the given face to its infinite boundary, if possible.  See: https://cad.onshape.com/FsDoc/library.html#BoundingType

    Internally, when selecting the "Up to face" option in the extrude feature, you are actually selecting UP_TO_SURFACE enum.  See the implementation here:
    https://cad.onshape.com/documents/12312312345abcabcabcdeff/w/a855e4161c814f2e9ab3698a/e/0ef5bec0909d4235a5ca1ebb
    Jake Rosenfeld - Modeling Team
  • aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
    Thanks I have that all running now. :)

    I am now struggling to find a way to get a solid bodies that intersection another solid body, via evCollision ? Or qIntersection ?
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,310
    evCollision tells you if the bodies collide. If you want to find the resultant body created by the intersection of two bodies use opBoolean. qIntersection is the intersection of two queries (not what you want here). 
    Senior Director, Technical Services, EMEAI
  • aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
    Ni Neil, I am not after the intersection between the 2 bodies, I need given bodyA, what other bodies are intersecting bodyA, do I need to get all bodies and  recursively run evCollision to test which ones intersect bodyA? 
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,310
    evCollision will return an array of all collisions.
    Senior Director, Technical Services, EMEAI
  • aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
    So I could try to cycle through bodies 1 at a time testing evCollision against the selected body - if there is any collision arrays then that body intersects? Could the same thing be done with multiple qIntersextion?
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    edited October 2020
    @aaron_skidmore

    qIntersection is not a geometric concept.  It is just a simple set intersection.  For example if I had two queries that represented:

    [face1, face3, face5] and [face1, face2, face3]

    The intersection of those two queries is [face1, face3]

    Similar to qUnion and qSubtraction, it is just a way to combine, find the overlap, or remove queries from each other.  See: https://cad.onshape.com/FsDoc/library.html#qIntersection-array

    evCollision ( https://cad.onshape.com/FsDoc/library.html#evCollision-Context-map ) will happily collide with multiple bodies at once.  
    const collisions = evCollision(context, { "tools" : bodyA, "targets" : qEverything(EntityType.BODY) -> qBodyType(BodyType.SOLID) });
    
    var targetBodyArray = [];
    for (var collision in collisions)
    {
        targetBodyArray = append(targetBodyArray, collision.targetBody)
    }
    
    // To de-duplicate, since collisions are per-face/edge
    const allTargetBodies = qUnion(targetBodyArray);
    
    debug(context, allTargetBodies);


    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    The weird -> thing is supposed to just be "->".  Not sure what's going on there...
    Jake Rosenfeld - Modeling Team
  • aaron_skidmoreaaron_skidmore Member Posts: 34 ✭✭
    Thanks for you help guys - I will try and get that to work - i think I have bitten off more than I can chew for my first go at a FeatureScript!
Sign In or Register to comment.