Welcome to Feature Script - Modify to fSphere

bruce_williams
bruce_williams Member, Developers Posts: 842 EDU
edited January 2017 in FeatureScript
I am playing with Cody's simple intro of 90 second FS to make cylinder.  No problem with fCylinder and fCuboid.  

When I try fSphere I get error -- Precondition failed (isLength(definition.radius, NONNEGATIVE_LENGTH_BOUNDS))

Here is the code -

FeatureScript 477;
import(path : "onshape/std/geometry.fs", version : "477.0");

annotation { "Feature Type Name" : "My Feature" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "My Length" }
        isLength(definition.myLength, LENGTH_BOUNDS);
        // Define the parameters of the feature type
    }
    {
        fSphere(context, id, definition.myLength);
    });

What is the fSphere needing to work?


www.accuratepattern.com

Best Answer

Answers

  • William_Barron
    William_Barron Member Posts: 5 ✭✭
    This works (I haven't looked at Cody's stuff)...

    annotation { "Feature Type Name" : "My Feature" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Radius" }
            isLength(definition.radius, LENGTH_BOUNDS);
            // Define the parameters of the feature type
        }
        {
            fSphere(context, id, definition);
        });

  • bruce_williams
    bruce_williams Member, Developers Posts: 842 EDU
    Thank you for the quick answer @William_Barron !  It greatly helps to see your solution and not be 'stuck' on this point.  

    I have a LONG ways to go....  Folks like you that help out on the forum make it feel even more possible to learn FS.
    www.accuratepattern.com