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.

Referencing a line from a sketch

I just started using FeatureScript.
I am trying to create a revolve part by using a line from a sketch as my revolution axis.
How can I reference it? I tried to create a variable but no success.
Here is the code:

        var sketch2 = newSketch(context, id + "sketch2", {
                "sketchPlane" : definition.sPlane
        });
        
       skLineSegment(sketch2, "line3", {
                "start" : vector(0, 0) * meter,
                "end" : vector(0 ,0.1 ) * meter
        });
        
        skSolve(sketch2);
        
        var section= qSketchRegion(id + "sketch1");
        
        opRevolve(context, id + "revolve1", {
                "entities" : section,
                "axis" : line(vector(0, 0, 0) * meter, vector(0, 0, 0.1)*meter),
                "angleForward" : 360 * degree
        });

The problem is it only works if the selected plan is Right or Front. I would like to use the line created in sketch2.

Thank you

If I try to use: qCreatedBy(id + "sketch2",EntityType.EDGE) for the axis,I get an error:

@opRevolve: Line should have an origin.

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    By hovering over the opRevolve function call (or looking up the opRevolve docs), we can see that "axis" needs to be of type Line (a data structure with an origin and a direction). qCreatedBy returns a Query (a specification which finds the entity or entities you want in the current Context), but not a Line.

    In FeatureScript, the way to get information (like the position or direction) from the geometry you query is with evaluate functions. In your case, you could use either evLine or evAxis:
    qCreatedBy(id + "sketch2",EntityType.EDGE)
    });
    opRevolve(context, id + "revolve1", {
            "entities" : section,
            "axis" : revolveAxis,
            "angleForward" : 360 * degree
    });
    const revolveAxis is Line = evAxis(context, {
            "axis" : 
    This should be a useful/common pattern in FS. You can see another example with more explanation on this step of the slot tutorial.
  • arnaud_glacet673arnaud_glacet673 Member Posts: 2
    Great, thank you
    I definitely need to spend more time reading the doc.
Sign In or Register to comment.