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.
The case of editing logic function usage.
konstantin_shiriazdanov
Member Posts: 1,221 ✭✭✭✭✭
Im' trying to automate the process of getting mate connectors owned by selected bodies into the list input ( with options to define some associated orientation data from enum parameter). But seems like when editing logic function is set the feature treats my attempt to edit list input parameter as a signal to refresh input field. Am I doing something wrong?
Here is the feature https://cad.onshape.com/documents/dac32e8d473681a47870141f/w/6061a9a3ea3fe56c74a037fb/e/1bee88dc7878a28fe9eaf056
The editing logic function looks like this:
export function modifyMCArr(context is Context, id is Id, oldDefinition is map, definition is map, isCreating is boolean, specifiedParameters is map) returns map
{
var partsMCQueries = qMateConnectorsOfParts(oldDefinition.parts)->qOwnedByBody(EntityType.VERTEX);
if (isCreating/* && !specifiedParameters.MCs*/)
{
definition.MCs = [];
for (var MC in evaluateQuery(context, partsMCQueries))
{
definition.MCs = append(definition.MCs, { "query" : MC, "orientation" : CoordSystemOrientation.ZERO });
}
return definition;
}
}
{
var partsMCQueries = qMateConnectorsOfParts(oldDefinition.parts)->qOwnedByBody(EntityType.VERTEX);
if (isCreating/* && !specifiedParameters.MCs*/)
{
definition.MCs = [];
for (var MC in evaluateQuery(context, partsMCQueries))
{
definition.MCs = append(definition.MCs, { "query" : MC, "orientation" : CoordSystemOrientation.ZERO });
}
return definition;
}
}
0
Comments
Did you mean to use 'oldDefinition' where you check the parts?
Also, if isCreating is false, your function does not live up to its promise of always returning a `map`.
IR for AS/NZS 1100
This involves your function settling on an answer to what happens when the sizes or content of definition.MCs and partsMCQueries differ.
Correct. Editing logic is called after every user change. oldDefinition contains the parameter values before the change, definition contains the parameter values after the change.
If you want your editing logic to only run when a certain parameter changes, you can simply add logic like