Why does this editing Logic query not work

dave_cowden
dave_cowden Member, Developers Posts: 484 ✭✭✭
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:
<br><div>FeatureScript 370;</div><div>import(path : "onshape/std/geometry.fs", version : "370.0");</div><div><br></div><div>annotation { "Feature Type Name" : "My Feature", "Editing Logic Function" : "editLogic" }</div><div>export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)</div><div>&nbsp; &nbsp; precondition</div><div>&nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; annotation { "Name" : "EDGE","Filter" : EntityType.EDGE }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; definition.edge is Query;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; annotation { "Name" : "Surface","Filter" : EntityType.FACE }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; definition.face is Query; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; debug(context,definition.face); &nbsp; &nbsp;</div><div>&nbsp; &nbsp; });</div><div><br></div><div>//You can also add a boolean argument to the cPlaneLogic function as the last argument&nbsp;</div><div>//(this is currently undocumented but it makes the logic function run when the feature is edited, not just created).</div><div>export function editLogic(context is Context, id is Id, oldDefinition is map, definition is map,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isCreating is boolean, specifiedParameters is map, hiddenBodies is Query) returns map {</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; if (oldDefinition == {} ){</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; var pnt = evEdgeTangentLine(context, {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "edge" : definition.edge,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "parameter" : 0</div><div>&nbsp; &nbsp; &nbsp; &nbsp; });</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var p = qNthElement(qContainsPoint(qEverything(EntityType.FACE),pnt.origin),1);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; debug(context,p);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; definition.face = p;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; return definition;</div><div>&nbsp; &nbsp;&nbsp;</div><div>}</div>

Answers

  • kori
    kori Onshape Employees Posts: 25 image
    This is a bug that will be fixed in the next update.  Thanks for reporting it!
  • dave_cowden
    dave_cowden Member, Developers Posts: 484 ✭✭✭
    alright thanks!