Sketches Created in Featurescript No Longer Appearing Under Feature

I have a feature written in Featurescript that creates a number of sketches. Previously, they were all showing up under the feature's details (when expanding the feature via arrow), but something changed and now they aren't. I'm not sure what changed.

What determines whether they show up? I don't get any arrow at all now next to the feature.

Best Answer

  • AsherAtSignalDesign
    AsherAtSignalDesign Member Posts: 34 PRO
    Answer ✓

    The problem turns out to be due to how the Id was being formed, I believe because the Id hierarchy was being broken. Fixing the Id assignments resolved the issue.

Answers

  • EvanReese
    EvanReese Member, Mentor Posts: 3,099 PRO

    I'd guess either you're deleting the sketches with opDelete() or they're not being created in the first place. Maybe you forgot to add a skSolve()?

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • _anton
    _anton Member, Onshape Employees Posts: 555 image

    Working for me. Share a document?

  • AsherAtSignalDesign
    AsherAtSignalDesign Member Posts: 34 PRO

    Definitely not deleting, definitely solving. The sketches show up as parts, just not in the list.

    FeatureScript 2737;
    import(path : "onshape/std/common.fs", version : "2737.0");
    
    annotation { "Feature Type Name" : "Create and Show Sketch", "Feature Type Description" : "" }
    export const sketchNotShown = defineFeature(function(context is Context, id is Id, definition is map)
        precondition {
            
            annotation {
                "Name" : "Parameter",
                "UIHint" : [UIHint.SHOW_LABEL, UIHint.REMEMBER_PREVIOUS_VALUE ],
                "Default": "value"
            }
            definition.parameter is string;
        }
        {
            const plane = plane( vector(0,0,0)*inch, vector( 0, 0, 1 ), vector( 1, 0, 0 ) );
            const sketch = newSketchOnPlane(context, id + "_sketch", {
                "Name" : "Sketch",
                "sketchPlane" : plane
            });
            skSolve(sketch);
        }
    );
    
    Screenshot 2025-08-08 at 4.22.51 PM.png
  • EvanReese
    EvanReese Member, Mentor Posts: 3,099 PRO

    Ah, the sketch is empty. It should show once you add geometry to it.

    FeatureScript 2737;
    import(path : "onshape/std/common.fs", version : "2737.0");
    
    annotation { "Feature Type Name" : "Create and Show Sketch", "Feature Type Description" : "" }
    export const sketchNotShown = defineFeature(function(context is Context, id is Id, definition is map)
        precondition {
            
            annotation {
                "Name" : "Parameter",
                "UIHint" : [UIHint.SHOW_LABEL, UIHint.REMEMBER_PREVIOUS_VALUE ],
                "Default": "value"
            }
            definition.parameter is string;
        }
        {
            const plane = plane( vector(0,0,0)*inch, vector( 0, 0, 1 ), vector( 1, 0, 0 ) );
            const sketch = newSketchOnPlane(context, id + "_sketch", {
                "Name" : "Sketch",
                "sketchPlane" : plane
            });
            skCircle(sketch, "circle1", {
                    "center" : vector(0, 0) * inch,
                    "radius" : 1 * inch
            });
            
            skSolve(sketch);
        }
    );
    
    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • AsherAtSignalDesign
    AsherAtSignalDesign Member Posts: 34 PRO

    Is it possibly something that I inadvertently toggled in the document settings-wise? It seems that the ability to hide the feature is also missing, which surprises me.

  • AsherAtSignalDesign
    AsherAtSignalDesign Member Posts: 34 PRO

    OK— that solved the example case.

    But my actual feature has contents in each sketch and still isn't showing up.

    I will have to try to create another example to show.

  • AsherAtSignalDesign
    AsherAtSignalDesign Member Posts: 34 PRO
    Answer ✓

    The problem turns out to be due to how the Id was being formed, I believe because the Id hierarchy was being broken. Fixing the Id assignments resolved the issue.

  • EvanReese
    EvanReese Member, Mentor Posts: 3,099 PRO

    Oh interesting that makes sense. Thanks for reporting back on your fix. It really helps people with similar issues searching the forum.

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com