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.
Queried entity type evaluation
konstantin_shiriazdanov
Member Posts: 1,221 ✭✭✭✭✭
Now if your query supports several entity types (geometry types, body types) and you need to process them differently you have to create a number of constructions like
if (try silent evSomethig is Somenting) {}
else if (try silent evSomethingElse is SomethingElse) {}
...
and it seems to be not very elegant for the task of finding out what entity/geometry/body contains the query.
Am I missing something or there is a reason to ask for implementation of function like evQueryContetntType(query) which should return a map like {"entityType":entityType, "bodyType": bodyType, ''geometryType":geometryType} for a query refferensing single entity.
if (try silent evSomethig is Somenting) {}
else if (try silent evSomethingElse is SomethingElse) {}
...
and it seems to be not very elegant for the task of finding out what entity/geometry/body contains the query.
Am I missing something or there is a reason to ask for implementation of function like evQueryContetntType(query) which should return a map like {"entityType":entityType, "bodyType": bodyType, ''geometryType":geometryType} for a query refferensing single entity.
2
Comments
For your case, can e.g. qGeometry() be used to do the job? If not, why not? We can certainly look into adding more queries like a qGeometry with multiple types, or a qHasAxis or qHasDirection to correspond with evAxis and evDirection.
For something like evSurfaceDefinition, I'd say your construction actually is good, canonical FeatureScript. One alternative is to wrap each in e.g. if(evaluateQuery(qGeometry(...)) != [] ). I think you'll find that the performance is about the same (since the ev functions themselves will fail early).
Go check out 'extractDirection(...)' in 'topoloyUtils.fs', as well as 'QueryFilterCompund.ALLOWS_DIRECTION' in 'query.fs'. It doesn't solve the wider problem you are asking about, but it is a built-in way of doing what you want in Measure Distance.
Found it:
https://forum.onshape.com/discussion/7074/feature-script-queried-entity-type-evaluation
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴