Looping Through Debugs Breaks unstableIdComponent

Alex_Kempen
Alex_Kempen Member Posts: 260 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 10553 Orange Overdrive


Comments