<p>Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.</p></p><strong>First time visiting? Here are some places to start:</strong></p><ol style="list-style:inherit;margin-left:25px;"><li>Looking for a certain topic? Check out the <a href="https://forum.onshape.com/categories">categories filter</a> or use Search (upper right).</li><li>Need support? <a href="https://forum.onshape.com/post/question/community-support">Ask a question</a> to our <a href="https://forum.onshape.com/categories/community-support">Community Support</a> category.</li><li>Please submit support tickets for bugs but you can request improvements in the <a href="https://forum.onshape.com/categories/product-feedback">Product Feedback category</a>.</li><li>Be respectful, on topic and if you see a problem, Flag it.</li></ol><p>If you would like to contact our Community Manager personally, feel free to <a href="https://forum.onshape.com/profile/6/LouGallo">send a private message</a> or <a href="mailto:lgallo@onshape.com">an email</a>.
</p>

Help... do you know what wrong it is?

joseph_ho608
joseph_ho608 Member Posts: 4 ✭

Comments

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,116 image
    edited August 2025

    Yes, what's wrong is that you used ChatGPT 😁

    Use the code snippets menu at the top. Also check out the learning reasources here:

    https://learn.onshape.com/learn/course/featurescript-fundamentals

    Senior Director, Technical Services, EMEA
  • joseph_ho608
    joseph_ho608 Member Posts: 4 ✭

    Not ChatGPT but Gemini, hehe😅

    I have fixed some and tried to spot out the rest but failed.

  • Matt_Shields
    Matt_Shields Member, Onshape Employees Posts: 990 PRO

    Ha, AI is not great at FS. This is valid code:

    FeatureScript 2737;
    import(path : "onshape/std/common.fs", version : "2737.0");
    
    annotation { "Feature Type Name" : "Offroad Wheel 1:12" }
    export const offroadwheel = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Wheel Diameter"}
            isLength(definition.diameter, { (millimeter) : [0, 60, 1000] } as LengthBoundSpec);
            
            annotation { "Name" : "Wheel Width", "Default" : 30 * millimeter }
            isLength(definition.width, LENGTH_BOUNDS);
    
            annotation { "Name" : "Number of Holes", "Default" : 6 }
            isInteger(definition.holes, POSITIVE_COUNT_BOUNDS);
        }
        {
            const diam = definition.diameter;
            const width = definition.width;
            const holes = definition.holes;
    
            var wheelsketch = newSketch(context, id + "wheelSketch", {
                    "sketchPlane" : qCreatedBy(makeId("Top"), EntityType.FACE)
                });
            skLineSegment(wheelsketch, "line1", {
                        "start" : vector(0, 0) * millimeter,
                        "end" : vector(0 * millimeter, width)
                    });
            skArc(wheelsketch, "arc1", {
                        "start" : vector(0 * millimeter, width),
                        "mid" : vector(diam, width),
                        "end" : vector(diam, 0 * millimeter)
                    });
    
            skSolve(wheelsketch);
        });