Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

Implicit mate fails, then works

EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
I'm still trying to get implicit mate connectors working for Freeform Spline. I'm having an issue like this: When an implicit mate connector is selected, it just says "missing entity" and fails, but if I click again, it works. A few things I've noticed:
  • It only happens if the XYZ values of the active point are not zero. The first click re-sets them to zero, then the second click works.
  • When the definition is returned by an Editing Logic Function, all of the implicit mate connectors in the feature go from saying "Mate Connector" to "Part of Mate Connector" and the query type goes from "queryType : CREATED_BY" to "queryType : DUMMY".
This all seems related, but I'm having a hard time understanding it. Any ideas? Here's a gif of what I'm talking about.
Evan Reese

Answers

  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    edited March 2021
    Okay, I spent an hour or so poking around and playing with things in a copy of your document here. I also rearranged some things to make diagnosing things a bit clearer. After some time, I managed to isolate sections of code causing your issues, but I can't really explain why they're causing you problems (especially since your editing logic isn't changing or updating definition.vertices[i].referenceSelection directly). Here are my findings:

    Selecting a mate connector, then adding or deleting an array item causes any selected mate connector queries to get turned into Part of Mate Connector dummy queries. The cause of this is the following statement in the editing logic:
    if (arrayItemAddedOrDeleted(oldDefinition.vertices, definition.vertices) && definition.vertices != [])
        {
            for (var i = 0; i < size(definition.vertices); i += 1)
            {
                definition.vertices[i].arrayPointIndex = i + 1; // stopping before this statement fixes this problem
            }
        }
    I also figured out the code which is causing the mate connector to immediately turn red and become invalid when selected. It's this piece of code here:
    // set the xyz offset to zero.
    definition.vertices[i].X = 0 * meter;
    definition.vertices[i].Y = 0 * meter;
    definition.vertices[i].Z = 0 * meter;
    I know both of these segments of code are the problems causing their respective issues because if you place a "return definition" statement before them, the issue doesn't occur. If you put it after them, it does. As to why these sections of code are causing problems specifically, I really can't say. Maybe someone who works for Onshape can shed some more light?
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    Possibly if something in editing logic function evaluated query for the verteces, and implicit mate connectors where there it could cause them to turn into dummy queries
  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    Thanks for taking so much time to look at it, Alex. 

    After trying to make the simplest possible recreation of the issue, it seems like implicit Mate Connectors inside array parameters get converted into dummy queries any time the editing logic function returns the definition, regardless of whether or not it changed anything about the implicit Mate Connector selection. It only does it when the Mate Connector selection is in an array param, not if it's just a normal query param. Here's that test feature. When I click the boolean to "invoke editing logic" all it does is change the string param from "NOT EDITED" to "EDITED" and return the definition, but you can see I'm still getting the dummy query. I think if that's all that happened in Freeform Spline, it would be a nuisance, since you can no longer click the icon to edit the Mate Connector, but I suspect this is part of what's causing it to fail on the first click too, which is a bigger issue. Does anyone at Onshape have an explanation and, better yet, a workaround?



    Evan Reese
  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    Very interesting. After some further testing, it seems that editing an array causes mate connectors to become dummy queries, and if the editing logic is called and edits something inside an array parameter when a mate connector is selected, the mate connector immediately breaks. Notably, however, this isn't the case if arrays are left alone:
    export function testEL(context is Context, id is Id, oldDefinition is map, definition is map,
        isCreating is boolean, specifiedParameters is map, hiddenBodies is Query) returns map
    {
        definition.toggle = !definition.toggle;
    
        if (definition.editingLogic)
        {
            definition.item[0].myString = "EDITED";
            definition.item[0].arrayToggle = !definition.item[0].arrayToggle;
        }
    
        return definition;
    }
    Unfortunately, it seems like this is a bug which is here to stay, at least for a little while.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



Sign In or Register to comment.