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:
<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> precondition</div><div> { </div><div> annotation { "Name" : "EDGE","Filter" : EntityType.EDGE }</div><div> definition.edge is Query; </div><div> </div><div> annotation { "Name" : "Surface","Filter" : EntityType.FACE }</div><div> definition.face is Query; </div><div> }</div><div> {</div><div> debug(context,definition.face); </div><div> });</div><div><br></div><div>//You can also add a boolean argument to the cPlaneLogic function as the last argument </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> isCreating is boolean, specifiedParameters is map, hiddenBodies is Query) returns map {</div><div> </div><div> if (oldDefinition == {} ){</div><div><br></div><div> var pnt = evEdgeTangentLine(context, {</div><div> "edge" : definition.edge,</div><div> "parameter" : 0</div><div> });</div><div> </div><div> var p = qNthElement(qContainsPoint(qEverything(EntityType.FACE),pnt.origin),1);</div><div> debug(context,p);</div><div> definition.face = p;</div><div> </div><div> }</div><div> return definition;</div><div> </div><div>}</div>
0
Answers