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.
error on set attribute
papawo
Member, Developers Posts: 206 PRO
i have query 1(featurelist) and query 2 (face);
if i choose query1, set attribute "entities" : entity,;
if i choose query2, set attribute"entities" : entity,
why do i get error when i choose query2? error is "@setAttribute: CANNOT_RESOLVE_ENTITIES"
if i choose query1, set attribute "entities" : entity,;
if i choose query2, set attribute"entities" : entity,
why do i get error when i choose query2? error is "@setAttribute: CANNOT_RESOLVE_ENTITIES"
0
Best Answer
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646You could do something like:
if (size(evaluateQuery(context, query2)) > 0) { // set attribute on query 2 } else { // behavior if query 2 is empty }
or eventry { // set attribute on query 2 } catch { // behavior if query 2 is empty }
I don't fully understand your question, but it should be simple to check whether query 2 has any content at the very beginning of your feature and just fail out if it doesn't.
Typically when we write our features internally, we use the following pattern to make sure Querys have actually been selected:// In the precondition annotation { "Name" : "Face to annotate" } definition.query2 is Query; // At the beginning of the feature body if (size(evalauteQuery(context, definition.query2)) == 0) { // First parameter is the error to throw, second parameter is the // field that should be highlighted red in the feature dialog. throw regenError("Select face to annotate.", ["query2"]); }
Jake Rosenfeld - Modeling Team5
Answers
so how should i do it then? user need to choose either of the 2 query.
or even
I don't fully understand your question, but it should be simple to check whether query 2 has any content at the very beginning of your feature and just fail out if it doesn't.
Typically when we write our features internally, we use the following pattern to make sure Querys have actually been selected:
precondition of setattribute failed (definition entities is query)
In cases like this, using `println` to print out the values of certain variables at certain points in your code can be a very useful debugging technique.