FS Frame

graham_lock
graham_lock Member Posts: 277 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

  • MichaelPascoe
    MichaelPascoe Member Posts: 2,955 PRO
    edited September 2024 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)
                    });
        });
    
    
    

    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚

Answers

  • MichaelPascoe
    MichaelPascoe Member Posts: 2,955 PRO
    edited September 2024 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)
                    });
        });
    
    
    

    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚
  • graham_lock
    graham_lock Member Posts: 277 PRO

    Thank you.