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.

Script for generating spheres (fSphere)

anass_assadikianass_assadiki Member Posts: 2
Hello All,

I am still new to FeatureScript. I am trying to write a FS to generate spheres taking in the following input:
- Radius
- X,Y,Z coordinates of the center

Here is what I could do so far and I don't know how to more further. I don't know what to do with the coordinates..

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

annotation { "Feature Type Name" : "drawSphere" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        // Define the parameters of the feature type
        annotation { "Name" : "Radius" }
        isLength(definition.Radius, NONNEGATIVE_LENGTH_BOUNDS);
       
        annotation { "X" : "X coord" }
        isLength(definition.Xcoord, LENGTH_BOUNDS);
       
        annotation { "Y" : "X coord" }
        isLength(definition.Ycoord, LENGTH_BOUNDS);
       
        annotation { "Z" : "Z coord" }
        isLength(definition.Zcoord, LENGTH_BOUNDS);
       
    }
    {
        // Define the function's action
       
        fSphere(context, id, definition.Radius);
       
    });

Any help would be appreciated, thank you.

A.A.



Comments

  • paul_chastellpaul_chastell Onshape Employees Posts: 124
    I would suggest you use opSphere, which is the operation, not fSphere. This also has in-context documentation and an example which shows how to pass the values:

            opSphere(context, id, {
                    "radius" : 1 * inch,
                    "center" : vector(1, 1, 1) * inch
            });

    Paul Chastell
    TVP, Onshape R&D
Sign In or Register to comment.