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.

Creating an extrusion using dimensions of face parallel to sketch plane.

Edward_HarrisEdward_Harris Member Posts: 7 PRO
edited August 2022 in FeatureScript
Hello. I am trying to learn FS, and as a step in a larger project, I am trying to get my feature to create an extrusion with the same sketch dimensions as a face parallel to the sketch surface but I am at a loss as to how to best go about this. Do you have any suggestions?

So far I have managed to create a sketch plane where I want the extrusion to be placed, but I am unsure as to which function, query/evaluate, to use in order to get the dimensions of the parallel face and also how I would go about this in general. The main automation in this feature should lie in the identification of the sketch dimensions, the height of the subsequent extrusion is irrelevant at this time.

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

annotation { "Feature Type Name" : "Podium Box" }
export const myBox = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Top Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
        definition.Topface is Query;

        annotation { "Name" : "Sketch Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
        definition.SFace is Query;

    }
    {
        //Figure some stuff out      
        var Faceedges = qEdgeVertex(definition.Topface, true);
               
        //Create a drawing plane
        var sketchPlane = evPlane(context, {
                "face" : definition.SFace
        });
        
        debug(context, Faceedges);
        
        debug(context, sketchPlane);
        
        //Create a Sketch
        var faceSketch = newSketchOnPlane(context, id + "sketchFaceplane", {
                "sketchPlane" : sketchPlane
            });
        
        //Draw Stuff        
        skRectangle(faceSketch, "rectangle1", {
                  "firstCorner" : qBodyType(definition.Topface, EntityType.EDGE)* millimeter,
                  "secondCorner" : vector(50, 50) * millimeter
        });
        
        //Solve Sketch
         skSolve(faceSketch);
               

        //  opExtractWires(context, id + "opExtractWires1", {
        //     "edges" : FaceEdges
        //});

        //   debug(context, FaceEdges, DebugColor.BLUE);
        // Define the function's action
    });

I have been stuck for 3 days now, any help would be greatly appreciated.
Best regards

Edward

Comments

  • EvanReeseEvanReese Member, Mentor Posts: 2,188 ✭✭✭✭✭
    edited August 2022
    Based on your code comments it looks like you've watched the videos from @adamohern. Great resource! This should be doable, and it's all about querying the right thing and evaluating its length. Will you annotate your screenshot to show which dimensions you want to get at with FS to reference?

    Evan Reese
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    Why opExtractWires? opExtrude is what you need.
    Senior Director, Technical Services, EMEAI
  • Edward_HarrisEdward_Harris Member Posts: 7 PRO
    Based on your code comments it looks like you've watched the videos from @adamohern. Great resource! This should be doable, and it's all about querying the right thing and evaluating its length. Will you annotate your screenshot to show which dimensions you want to get at with FS to reference?

    I hope the annotations make it more clear as to what I am trying to query, and yes, what and how to query it have been my biggest challenge, as well as how to call it in a function.
  • brooke_spreenbrooke_spreen Member, Developers Posts: 115 ✭✭✭
    Geometry is generally easier to work with than sketches in Featurescript (perhaps even in Onshape in general ;) ). Here's one solution - link
    Design Engineer | Anerdgy AG
  • Edward_HarrisEdward_Harris Member Posts: 7 PRO
    Geometry is generally easier to work with than sketches in Featurescript (perhaps even in Onshape in general ;) ). Here's one solution - link
    I'll give this a go, anything that can simplify the process is a big help haha! :)
  • Edward_HarrisEdward_Harris Member Posts: 7 PRO
    Based on your code comments it looks like you've watched the videos from @adamohern. Great resource! This should be doable, and it's all about querying the right thing and evaluating its length. Will you annotate your screenshot to show which dimensions you want to get at with FS to reference?

    Do you have any suggestions as to what I should query?
  • brooke_spreenbrooke_spreen Member, Developers Posts: 115 ✭✭✭
    I'll give this a go, anything that can simplify the process is a big help haha! :)
    Any luck? :)

    Design Engineer | Anerdgy AG
Sign In or Register to comment.