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.

How to using FS to create a quick sphere

tsung_ren_hungtsung_ren_hung Member Posts: 9 EDU
edited July 2016 in FeatureScript
I tried using FS to quickly create a sphere
but it still not work.
where is the problem?

thanks

https://cad.onshape.com/documents/578f89d3e4b0cdd13940cfe7/w/92807c44d555c353a9b7b4b3/e/d9b77e1c239e6135100324f8


Best Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,308
    edited July 2016 Answer ✓
    Sorry, the documentation is wrong - center should be a query not a length vector. 
    annotation { "Feature Type Name" : "Quick Sphere" }
    export const quickSphere = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Select sphere center", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
            definition.center is Query;
            
            annotation { "Name" : "Sphere size" }
            isLength(definition.sphereSize, LENGTH_BOUNDS);
        }
        {
         
            sphere(context, id + "sphere1", {
                    "center" : definition.center,
                    "radius" : definition.sphereSize / 2
            });
        });
    If you need to specify a vector, please use fEllipsoid:
        fEllipsoid(context, id + "sphere", {
                "center" : vector(0, 0, 0) * inch,
                "radius" : vector(definition.sphereSize / 2, definition.sphereSize / 2, definition.sphereSize / 2)
        });

    Senior Director, Technical Services, EMEAI

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,308
    edited July 2016 Answer ✓
    Sorry, the documentation is wrong - center should be a query not a length vector. 
    annotation { "Feature Type Name" : "Quick Sphere" }
    export const quickSphere = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Select sphere center", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
            definition.center is Query;
            
            annotation { "Name" : "Sphere size" }
            isLength(definition.sphereSize, LENGTH_BOUNDS);
        }
        {
         
            sphere(context, id + "sphere1", {
                    "center" : definition.center,
                    "radius" : definition.sphereSize / 2
            });
        });
    If you need to specify a vector, please use fEllipsoid:
        fEllipsoid(context, id + "sphere", {
                "center" : vector(0, 0, 0) * inch,
                "radius" : vector(definition.sphereSize / 2, definition.sphereSize / 2, definition.sphereSize / 2)
        });

    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.