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.

Using a closed loop sketch as path for opSweep

Hi,
I'm trying to use a sketch inside FS as a path for the opSweep function. 
It works fine when the sketch contains a few connected lines, but it throws an error as soon as it becomes a closed-loop (e.g. a rectangular path). 
Any idea how it can be resolved?

        var path1 = newSketch(context, id + "path1", {
                "sketchPlane" : qCreatedBy(makeId("Front"), EntityType.FACE)
            });
        skRectangle(path1, "rectangle1", {
                    "firstCorner" : vector(0, 0) * inch,
                    "secondCorner" : vector(10, 10) * inch
                });
        // Create sketch entities here
        skSolve(path1);

        var profile1 = newSketch(context, id + "profile1", {
                "sketchPlane" : qCreatedBy(makeId("Top"), EntityType.FACE)
            });
        skCircle(profile1, "circle1", {
                    "center" : vector(0, 0) * inch,
                    "radius" : 0.5 * inch
                });
        // Create sketch entities here
        skSolve(profile1);


        opSweep(context, id + "sweep1", { // @opSweep: SWEEP_SELECT_PATH
                    "bodytype" : ToolBodyType.SOLID,
                    "operationType" : NewBodyOperationType.NEW,
                    "profiles" : qCreatedBy(id + "profile1", EntityType.FACE),
                    "path" : qCreatedBy(id + "path1", EntityType.EDGE)
                });



and the error message:

@opSweep: SWEEP_PATH_FAILED
onshape/std/geomOperations.fs (const opSweep)
onshape/std/feature.fs (defineFeature)
Case Carcass (const plyBody)

Best Answer

  • Jacob_CorderJacob_Corder Member Posts: 67 PRO
    Answer ✓
    @mortezaPourmohamadi

    Did you try Kontstantins solution? When sketches are solved, the entites become wire bodies. It is also true that multiple edges are created as Konstantin stated above.

    for the profile you could use
    sketchEntityQuery(id+"profile1", EntityType.EDGE, "circle1");
    or
    qAdjacent(qCreatedBy(id+"profile1",EntityType.FACE),AdjacencyType.EDGE,EntityType.EDGE)
      
    for the path if it is closed, qAdjacent(qCreatedBy(id+"path1",EntityType.FACE),AdjacencyType.EDGE,EntityType.EDGE)
    or
    sketchEntityQuery(id+"path1", EntityType.EDGE, "rectangle1");

Answers

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    I think it is because closed sketch creates multiple coinciding edges. Try this:
    "path" : qCreatedBy(id + "path1", EntityType.BODY)-> qBodyType(BodyType.WIRE)->qOwnedByBody(EntityType.EDGE)

  • mortezaPourmohamadimortezaPourmohamadi Member Posts: 8 PRO
    Thanks @konstantin_shiriazdanov

    This didn't solve the issue, though. There is no BODY in the "path1" sketch, so the resulting WIRE and EDGE list would be empty.
  • Jacob_CorderJacob_Corder Member Posts: 67 PRO
    Answer ✓
    @mortezaPourmohamadi

    Did you try Kontstantins solution? When sketches are solved, the entites become wire bodies. It is also true that multiple edges are created as Konstantin stated above.

    for the profile you could use
    sketchEntityQuery(id+"profile1", EntityType.EDGE, "circle1");
    or
    qAdjacent(qCreatedBy(id+"profile1",EntityType.FACE),AdjacencyType.EDGE,EntityType.EDGE)
      
    for the path if it is closed, qAdjacent(qCreatedBy(id+"path1",EntityType.FACE),AdjacencyType.EDGE,EntityType.EDGE)
    or
    sketchEntityQuery(id+"path1", EntityType.EDGE, "rectangle1");
  • mortezaPourmohamadimortezaPourmohamadi Member Posts: 8 PRO
    Thanks @Jacob_Corder

    This worked beautifully!  :)
Sign In or Register to comment.