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.

Gotcha! qCapEntity returns no START cap unless extrusion was orthogonal to the world

blackslateblackslate Member Posts: 16
To see a demo of this issue, please visit my Extrude Cap Test document and double-click on the Extrude Cap Test feature to open the dialog and show debug feedback.

In Debug Mode, you should see a red plane and a green face. The face is the result of the query of the type: qCapEntity(extrudeId, CapType.START, EntityType.FACE). All well and good.

However, if you deselect either "Sketch on world plane" or "Extrude along world axis", the green debug feedback will disappear. In the FeatureScript notices, you will see:

capFace START debug: Query resolves to nothing

If you choose to show the END cap in the dialog, you will see two green debug faces,  the notice "capFace END debug: Query resolves to 2 faces".

I expected to see one START cap face and one END cap face for every extrude, regardless of the plane on which the sketch is drawn and the extrusion direction. Have I misunderstood something?




Best Answer

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,688
    Answer ✓
    Yep, looks like a bug.
    Senior Director, Technical Services, EMEAI

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,688
    Answer ✓
    Yep, looks like a bug.
    Senior Director, Technical Services, EMEAI
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,688
    As an interim workaround, you could:
            if (definition.capType == CAP_TYPE.START)
            {
                capFace = qCapEntity(extrudeId, CapType.START, EntityType.FACE);
                
                if(isQueryEmpty(context, capFace))
                {
                    capFace = qCoincidesWithPlane(qCapEntity(extrudeId, CapType.END, EntityType.FACE), sketchPlane);
                }
            } 

    Senior Director, Technical Services, EMEAI
  • blackslateblackslate Member Posts: 16
    Thanks for your confirmation that this is not pilot error, Neil!

    I've updated my Extrude Cap Test document, and now you can:
    1. Reproduce the bug with all EntityType's
    2. Choose to use an overloaded version of qCapEntity(), which (I believe) fixes the bug, and which should simply fall back to using the built-in version of qCapEntity() when this bug gets fixed.

    I have two related questions about good practice:
    1. I overloaded qCapEntity() with a new signature. For scripts which might be used by other FeatureScript writers, is this good practice?
    2. I wrote a function called qyDoesntCoincideWithPlane(), where I deliberately use "qy" so that it is clear that this is not a built-in function. Is this also good practice?



  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,688
    There are no standards set, but it's probably best to avoid overloading built-ins. Your parameters are different so you would have to edit your code when it gets fixed anyway, so probably best to give the function a unique name also.
    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.