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.

Looping Through Debugs Breaks unstableIdComponent

Alex_KempenAlex_Kempen Member Posts: 248 EDU
It turns out that looping through any debug function (such as addDebugPoint and addDebugArrow) causes any features inside the same loop which rely on unstableIdComponent to break. Notably, the output of features which rely on unstableIdComponent still happen, but the output becomes unusable by other features downstream - attempting to select resulting entities later on fails.

Here's an example of code which triggers this bug:
        var debugs = 0;
        var evaluatedQuery = evaluateQuery(context, definition.vertices);
        for (var i = 0; i < size(evaluatedQuery); i += 1)
        {
            if (definition.debug && debugs != 2)
            {
                addDebugPoint(context, vector(0, 0, i) * inch);
                debugs += 1;
            }
            
            const location = evVertexPoint(context, { "vertex" : evaluatedQuery[i] });
            // works fine if fCylinder's id is: id + ("loopCylinder" ~ i)
            fCylinder(context, id + "loopCylinder" + unstableIdComponent(i), {
                        "topCenter" : location,
                        "bottomCenter" : location + vector(0, 0, 1) * inch,
                        "radius" : 1 * inch
                    });
        }


Notably, this bug does not occur if the ids of features inside the loop don't contain an unstableIdComponent, or if the debug function is called only once inside the for loop. It also doesn't occur if the debug function is called inside a separate loop.

here's a link to the document:
https://cad.onshape.com/documents/d081fcb70539dbdda9452c2d/w/5fbf50aa7c6397126cbe81c8/e/49708cc3cc782f88295bd173

@lougallo, can you get this logged?
Software Developer at Epic Systems
FRC Design Mentor - Team 1306 BadgerBots


Comments

  • lanalana Onshape Employees Posts: 727
    Thank you @Alex_Kempen. Good catch! Logging.

  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,056 ✭✭✭✭✭
    @Alex_Kempen
    Does it still happen if you use setExternalDisambiguation with the vertex and the id with the unstableIdComponent?
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    I believe setExternalDisambiguation doesn't affect it since I first encountered the bug while troubleshooting a function which utilized setExternalDisambiguation properly.
    Software Developer at Epic Systems
    FRC Design Mentor - Team 1306 BadgerBots


  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,056 ✭✭✭✭✭
    Ok. I just tested it and it doesn't work with setExternalDisambiguation
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
Sign In or Register to comment.