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.

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

joseph_ho608joseph_ho608 Member Posts: 4

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,891
    edited August 15

    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_ho608joseph_ho608 Member Posts: 4

    Not ChatGPT but Gemini, hehe😅

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

  • Matt_ShieldsMatt_Shields Member, Onshape Employees Posts: 698 EDU

    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);
        });
    
    
Sign In or Register to comment.