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.
How can I determine the entity or geometry type of a selected entity?
joshtargo
Member Posts: 454 EDU
Do I need to have a qGeometry for every possible type, or is there a way for it to just look at a query and tell me what it is?
0
Comments
check out:
evCurveDefinition
and
evSurfaceDefinition (context is Context, arg is map) returns map
Return a descriptive value for a face, or the first face if the query finds more than one. Return a
Cone,Cylinder,Plane,Sphere,Torus, orBSplineSurfaceas appropriate for the face, or an unspecified map value if the face is none of these with surfaceType filled of type SurfaceTypeI was hoping there was a function that simply tells you what kind of entity something is. I want the user to be able to click on a vertex, edge, arc, circle, or face, but the processing is different depending on which one it is.
@joshtargo Well, there is, it's qEntityType. But that gets you one of the following: Vertex, Edge, Face, or Body. If you want it to return the geometry type, you could do qGeometryType. If you want the body type then qBodyType. I recommend making a custom function to use all of them together to return a custom type from a custom enum. You can do the initial filtering with qEntityType, then from there use evCurveDefinition or evSurfaceDefinition to get specifics.
I imagine you could do it in 10 minutes 😎. Then save it to your FS library where you can import it and re-use it per project.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Do t I need to use the specific types I'm looking for as arguments for those functions? I wanted something that returns "vertex" or "arc"
If you want the query for specific entity types, you can do something like this:
For finding an arc it could be more like this:
// No doubt there are cleaner ways to do this, I'm just throwing something out there for you to start. // Also, the try catch doesn't work well, so perhaps this isn't the best approach. // I would expect the "try" to forget the attempt if it fails, but for some reason this isn't // the case with FeatureScript, which makes the try/catch pointless if it will not consistently trigger the // catch and forget what happened in the try. As you can tell… I've had some bones to pick in the past with FS try/catch. const isEdge = !isQueryEmpty(context, qEntityFilter(queryToFilter, EntityType.EDGE))); var isArc = false; if (isEdge) { try silent { var radius = evCurveDefinition(context, { "edge" : definition.entitiesArray[0] }).radius; isArc = true; } }Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
its similar to what I ended up doing, I guess there is no built in function that returns an entity type, which seems strange.
My solution was: