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.

convert entities into sketch

adamohernadamohern Member, OS Professional Posts: 216 PRO
How can I convert the edges of a queried face into a sketch created in FS?

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    We don't have this functionality in FeatureScript yet. The way it works in interactive sketches is that the right sketch entities are created as generated FS and constrained to be projections of the source.

    Often, the simplest workaround for this is to use the face directly in other operations (for instance, extrude using face as entities, but choose direction, start and end bounds as needed). If you need it as a separate body, opExtractSurface may also be useful.

    Of course, one power of "use" is that is gives you a projection of the edges into a plane. For this, a workaround is to make a planar surface and use opSplitFace with your edges. This gives you a surface body with multiple faces and edges.

  • tim_lucas238tim_lucas238 Member Posts: 3
    It's 2020 and I still cannot see this functionality in there?
    This is pretty basic functionality that I use with a single click in Solidwoks almost every time. In Solidworks I have commands like this assigned to a single button press on my 3D mouse, total deal breaker for me. I am not interested in workarounds for basic one click sketch functions.
    Will check back in a year and see if Onshape has caught up.

  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    It's 2020 and I still cannot see this functionality in there?
    This is pretty basic functionality that I use with a single click in Solidwoks almost every time. In Solidworks I have commands like this assigned to a single button press on my 3D mouse, total deal breaker for me. I am not interested in workarounds for basic one click sketch functions.
    Will check back in a year and see if Onshape has caught up.

    This thread is in reference to doing it within a custom feature's code. To just convert entities in a sketch click "Use" or press "u".
    Evan Reese
  • tim_lucas238tim_lucas238 Member Posts: 3
    Thanks for replying, that was exactly what I was looking for.

  • fer_fer_fer_fer_ Member Posts: 6 ✭✭
    adamohern said:
    How can I convert the edges of a queried face into a sketch created in FS?
    I have the same doubt as the user adamohern. 
    But in 2022 
    I would like to make a second tool generate a Project Sketch after using FeatureScript Auto Layout
    Untitled
  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    @fer_fer_
    is the goal to make a sketch of the flat pattern in order to get a dxf?
    Evan Reese
  • fer_fer_fer_fer_ Member Posts: 6 ✭✭

    @fer_fer_
    is the goal to make a sketch of the flat pattern in order to get a dxf?
    Yes, Taking as a reference the Top plane.
    (in the future to be able to list the parts of the laser cut)
  • Jacob_CorderJacob_Corder Member Posts: 137 PRO
    you could use opCreateOutline. That will project the faces onto the plane.

    otherwise

    you could extrude up to plane using opExtrude (up to plane may fail, it it does just extrude past the plane using the planes normal, then split the extruded body with the plane using opSplitFace. get the edges created by the split using qCreatedBy(id, EntityType.EDGE). this will give you the edge projections onto the plane. Extract the edges using opExtractWires or opFill to create a planar face. then delete the extruded body.

    below is just some code i had lying around. 
    annotation { "Feature Type Name" : "Drawing View Sketch" }
    export const drawingViewSketch = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
           annotation { "Name" : "Entities", "Filter" : EntityType.FACE || EntityType.BODY  }
           definition.tools is Query;
           annotation { "Name" : "target", "Filter" : EntityType.FACE && GeometryType.PLANE|| GeometryType.CYLINDER || GeometryType.EXTRUDED, "MaxNumberOfPicks" : 1 }
           definition.target is Query;
           annotation { "Name" : "Offset Faces", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
           definition.offsetFaces is Query;
           
        }
        {         
            DrawingViewSketch(context, id, definition);
        });
    export function DrawingViewSketch(context is Context, id is Id, definition is map)
    {
        var faces = evaluateQuery(context,qEntityFilter(definition.tools,EntityType.FACE));
        var bodies = qEntityFilter(definition.tools,EntityType.BODY);
        if(size(faces)>0)
        {
            opExtractSurface(context,id + "extractFaces",{"faces":qUnion(faces),"useFacesAroundToTrimOffset":false,"tangentPropagation":false});
        }
        definition.tools= qUnion([qCreatedBy(id,EntityType.BODY),bodies]);
        opCreateOutline(context,id,definition);     
        try silent(opDeleteBodies(context,id+"deleteBodies",{"entities":qCreatedBy(id + "extractFaces",EntityType.BODY)}));     
    }



  • fer_fer_fer_fer_ Member Posts: 6 ✭✭
    you could use opCreateOutline. That will project the faces onto the plane.


    Thanks for your reply @Jacob_Corder

    I have created a new document to be able to test your code, and by the way show what I want to do.


    Auto Layout - Nesting

Sign In or Register to comment.