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.
Why does this editing Logic query not work
dave_cowden
Member, Developers Posts: 475 ✭✭✭
I have a feature that accepts both an edge and a face. My goal is to use an editing logic function to pre-populate the face that contains the provide edge, if there is one.
In the example below, you can see that the editing logic does select a face. But then there is an error assigning it to the definition: "Editing logic result Parameter "face" does not satisfy spec. But it should, because it is clearly a query.
What am I missing?
Complete code:
In the example below, you can see that the editing logic does select a face. But then there is an error assigning it to the definition: "Editing logic result Parameter "face" does not satisfy spec. But it should, because it is clearly a query.
What am I missing?
Complete code:
FeatureScript 370;
import(path : "onshape/std/geometry.fs", version : "370.0");
annotation { "Feature Type Name" : "My Feature", "Editing Logic Function" : "editLogic" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "EDGE","Filter" : EntityType.EDGE }
definition.edge is Query;
annotation { "Name" : "Surface","Filter" : EntityType.FACE }
definition.face is Query;
}
{
debug(context,definition.face);
});
//You can also add a boolean argument to the cPlaneLogic function as the last argument
//(this is currently undocumented but it makes the logic function run when the feature is edited, not just created).
export function editLogic(context is Context, id is Id, oldDefinition is map, definition is map,
isCreating is boolean, specifiedParameters is map, hiddenBodies is Query) returns map {
if (oldDefinition == {} ){
var pnt = evEdgeTangentLine(context, {
"edge" : definition.edge,
"parameter" : 0
});
var p = qNthElement(qContainsPoint(qEverything(EntityType.FACE),pnt.origin),1);
debug(context,p);
definition.face = p;
}
return definition;
}
0
Best Answers
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565You may actually need to do:
qUnion(evaulateQuery(context, p))
We generally keep query input values as individual, evaluated queries, to make it easy to display them to a user as a list with names like "edge of ___", each with an x to delete it.
This behavior definitely needs better documenting (and possibly a better error). Sorry for that on both accounts!
5 -
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215This is a bug -- it's not fixed in the next update, but once the one after the next update ships, a feature using the latest FS will be able to do definition.face = p;, like you originally wanted without the qUnion(evaluate...) workaround.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5
Answers
qUnion(evaulateQuery(context, p))
We generally keep query input values as individual, evaluated queries, to make it easy to display them to a user as a list with names like "edge of ___", each with an x to delete it.
This behavior definitely needs better documenting (and possibly a better error). Sorry for that on both accounts!
Note in the above case the array syntax, which is the syntax most commonly used with qUnion.
If you use the array version, you
will get the same assignment error as above. In this case, you need to use the form without the array syntax, which I would never guess.