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.

FS Frame

graham_lockgraham_lock Member Posts: 160 PRO

Hi all,

Is there a recommended way of creating frames from within Featurescript?

I note there isn't an opFrame?

Thank you.

Best Answer

  • MichaelPascoeMichaelPascoe Member Posts: 2,012 PRO
    edited September 4 Answer ✓

    Here is an example of how to do this: Custom Frame Feature

    https://cad.onshape.com/documents/1c60214907841409142a986b/w/faab37dbe00c8aeb1722b6b8/e/3e205ad26efb4081ee…

    Currently, you have to import the frame feature in order to do this. See line 3.

    FeatureScript 2455;
    import(path : "onshape/std/common.fs", version : "2455.0");
    import(path : "12312312345abcabcabcdeff/6105196984064c2818b6eea9/7d39eff85eff86d560b39fd0", version : "250ae03e4007e9684f18a5ba");
    
    annotation { "Feature Type Name" : "Frame test", "Feature Type Description" : "" }
    export const frameTest = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation {
                        "Library Definition" : "65dcc2a02c4ff1c239467ec9", // This is the id of the Onshape Frame Profile Library definition
                        "Name" : "Sketch profile",
                        "Filter" : PartStudioItemType.SKETCH,
                        "MaxNumberOfPicks" : 1,
                        "UIHint" : UIHint.REMEMBER_PREVIOUS_VALUE
                    }
            definition.frameProfile is PartStudioData;
    
            annotation { "Name" : "Edges", "Filter" : EntityType.EDGE }
            definition.edges is Query;
        }
        {
            frame(context, id + "frame", {
                        "profileSketch" : definition.frameProfile,
                        "selections" : definition.edges,
                    //"angle" : definition.angle,
                    //"angleReference" : definition.angleReference,
                    //"defaultCornerType": FrameCornerType.MITER, "defaultButtFlip": false,
                    //"index" : definition.index,
                    //"trim" : true, "trimPlanes" : definition.trimPlanes, "trimBodies" : qNothing()
                    });
    
            const frames = qCreatedBy(id + "frame", EntityType.BODY);
    
            setProperty(context, {
                        "entities" : frames,
                        "propertyType" : PropertyType.APPEARANCE,
                        "value" : color(1, 1, 1)
                    });
        });
    
    
    


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴

Answers

  • MichaelPascoeMichaelPascoe Member Posts: 2,012 PRO
    edited September 4 Answer ✓

    Here is an example of how to do this: Custom Frame Feature

    https://cad.onshape.com/documents/1c60214907841409142a986b/w/faab37dbe00c8aeb1722b6b8/e/3e205ad26efb4081ee…

    Currently, you have to import the frame feature in order to do this. See line 3.

    FeatureScript 2455;
    import(path : "onshape/std/common.fs", version : "2455.0");
    import(path : "12312312345abcabcabcdeff/6105196984064c2818b6eea9/7d39eff85eff86d560b39fd0", version : "250ae03e4007e9684f18a5ba");
    
    annotation { "Feature Type Name" : "Frame test", "Feature Type Description" : "" }
    export const frameTest = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation {
                        "Library Definition" : "65dcc2a02c4ff1c239467ec9", // This is the id of the Onshape Frame Profile Library definition
                        "Name" : "Sketch profile",
                        "Filter" : PartStudioItemType.SKETCH,
                        "MaxNumberOfPicks" : 1,
                        "UIHint" : UIHint.REMEMBER_PREVIOUS_VALUE
                    }
            definition.frameProfile is PartStudioData;
    
            annotation { "Name" : "Edges", "Filter" : EntityType.EDGE }
            definition.edges is Query;
        }
        {
            frame(context, id + "frame", {
                        "profileSketch" : definition.frameProfile,
                        "selections" : definition.edges,
                    //"angle" : definition.angle,
                    //"angleReference" : definition.angleReference,
                    //"defaultCornerType": FrameCornerType.MITER, "defaultButtFlip": false,
                    //"index" : definition.index,
                    //"trim" : true, "trimPlanes" : definition.trimPlanes, "trimBodies" : qNothing()
                    });
    
            const frames = qCreatedBy(id + "frame", EntityType.BODY);
    
            setProperty(context, {
                        "entities" : frames,
                        "propertyType" : PropertyType.APPEARANCE,
                        "value" : color(1, 1, 1)
                    });
        });
    
    
    


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • graham_lockgraham_lock Member Posts: 160 PRO

    Thank you.

Sign In or Register to comment.