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

FS generated sketch to be accessible in Asseblies

MakotoNinjaMakotoNinja Member Posts: 4 EDU
Aloha All,

I am trying to write a FS that generates a sketch that is accessible from within Assemblies. What I am seeing is that a feature is generated with the sketch I have devised but this "sketch" isn't available to insert into an Assembly. Is there a way to create a sketch in FS that shows up as an actual sketch instead of a feature?
The first feature in the following image shows the sketch as generated by FS and the second feature in the list is a vanilla sketch created with the sketch button. Only the latter is available to insert into an Assembly.

I am new to FS but not new at programming. My code is as follows:
FeatureScript 1993;
import(path : "onshape/std/common.fs", version : "1993.0");

const BOUNDS = {(unitless) : [10, 100, 1e5]} as IntegerBoundSpec;

annotation { "Feature Type Name" : "Axes" }
export const axes = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
    // Define the parameters of the feature type
    annotation
    {
        "Name" : "Sketch Plane",
        "Filter" : EntityType.FACE,
        "MaxNumberOfPicks" : 1
    }
    definition.sketchPlane is Query;
    
    annotation
    {
        "Name" : "Diameter",
        "UIHint" : [UIHint.SHOW_LABEL, UIHint.REMEMBER_PREVIOUS_VALUE],
        "Description" : "Set the diameter of the circle"
    }
    // isLength(definition.radius, LENGTH_BOUNDS);
    isInteger(definition.diameter, BOUNDS);
}
{
    var diameter = definition.diameter;
    var splane = definition.sketchPlane;
    
    // Define the function's action
    var sketch1 = newSketch(context, id + "sketch1", {
        "sketchPlane" : splane
    });
    skCircle(sketch1, "circle1", {
        "center" : vector(0, 0) * millimeter,
        "radius" : (diameter / 2) * millimeter,
        "construction" : true
    });
    skLineSegment(sketch1, "line1", {
        "start" : vector(-diameter / 2, 0) * millimeter,
        "end" : vector(diameter / 2, 0) * millimeter,
        "construction" : true
    });
    skLineSegment(sketch1, "line2", {
        "start" : vector(0, diameter / 2) * millimeter,
        "end" : vector(0, -diameter / 2) * millimeter,
        "construction" : true
    });
    skSolve(sketch1);
});

Sign In or Register to comment.