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.

Options

What is wrong with my code

chisimdi_onyenze532chisimdi_onyenze532 Member Posts: 2
// Feature to create the frame for combat robot
export const createCombatRobotFrame = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Width", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
        definition.width is ValueWithUnits;
        annotation { "Name" : "Length", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
        definition.length is ValueWithUnits;
        annotation { "Name" : "Height", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
        definition.height is ValueWithUnits;
    }
    {
        // Define parameters for the frame
        const width = getParameter(definition, "width");
        const length = getParameter(definition, "length");
        const height = getParameter(definition, "height");
        
        // Create sketch for the frame
        const sketchPlane = plane(normalId: qCreatedBy(makeId("Top")), pointOnPlane: vector(0,0,0) * inch);
        const sketch = newSketch(context, {
            "sketchPlane" : sketchPlane
        });
        
        // Create frame geometry
        skRectangle(sketch, "frame", {
            "firstCorner" : vector(0, 0) * meter,
            "secondCorner" : vector(width, length) * meter
        });
        
        // Extrude the sketch to create the frame
        extrude(context, id + "frameExtrude", {
            "entities" : qSketchRegion(id + "frameSketch", true),
            "direction" : vector(0, 0, height) * meter,
            "endBound" : BoundingType.BLIND,
            "endBoundLength" : height * meter
        });
    }
);

Comments

  • Options
    NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,475
    edited April 6
    Where did you get this from? ChatGPT? Don't trust it, it knows nothing. The only way to do it properly is with research and effort.
    Senior Director, Technical Services, EMEAI
  • Options
    jnewth_onshapejnewth_onshape Member, Onshape Employees Posts: 67
    There is a FeatureScript learning pathway (tutorial) here: https://learn.onshape.com/courses/featurescript-fundamentals

    FeatureScript is a powerful domain-specific language. It obeys programming language conventions you mostly know, but where it's different, it's quite different, particularly around working with topology and geometry. The tutorials are the place to start.

    Without sharing the doc, it's hard to see your errors (look in the FeatureScript Notices panel). At the very least, nothing exists in your sketch until you `skSolve(..)` the sketch, but this should be apparent once you start doing the tutorials. 
Sign In or Register to comment.