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.

Is there an easier way to query for the YZ_PLANE?

izumi_matsudaizumi_matsuda Member Posts: 3
When using opSplitPart, I wanted the tool for the split to be the YZ_PLANE. However, the "tool" has to be a query.
The following works:
qEverything()->qParallelPlanes(YZ_PLANE)

However, is there a simpler way to do this?

Best Answer

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    Answer ✓
    qCreatedBy(makeId("Right"), EntityType.FACE)
    Senior Director, Technical Services, EMEAI

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    Answer ✓
    qCreatedBy(makeId("Right"), EntityType.FACE)
    Senior Director, Technical Services, EMEAI
  • daniel_cravensdaniel_cravens Member Posts: 29
    This post solved my issue getting opsplitpart to work. Converting my construction plane into a query worked. In case this helps anyone in the future the following creates a tool normal to a line and cuts the part.

    //////////////////////////////////////////////////////////////////////////////////////////////
    //
    //  Split Part with Plane Normal to Selected Edge
    //

    annotation { "Feature Type Name" : "Split Normal" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Select edge for split.", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 }
            definition.edge is Query;
            
        }
        {
            
            var endPoints is Query = qAdjacent(definition.edge, AdjacencyType.VERTEX, EntityType.VERTEX);


            var point1 is Vector = evVertexPoint(context, {
                    "vertex" : qNthElement(endPoints, 0)
            });
            var point2 is Vector = evVertexPoint(context, {
                    "vertex" : qNthElement(endPoints, 1)
            });
            
            var midPoint is Vector = point2 - point1;

            var body = qBodyType(qEverything(EntityType.BODY), BodyType.SOLID)->qContainsPoint(point1);
            var face = qOwnedByBody(body, EntityType.FACE)->qContainsPoint(point1)->qContainsPoint(point2);
            
            var tangentLine = evEdgeTangentLine(context, {
                    "edge" : definition.edge,
                    "parameter" : 0.5
            
            });
            
            var tangentPlane = evFaceTangentPlane(context, {
                    "face" : face,
                    "parameter" : vector(0.5, 0.5)
            });
            
            var normal is Vector = cross(tangentPlane.normal,tangentLine.direction);
            
            var plane = opPlane(context, id + "plane1", {
                    "plane" : { "origin" : point1, 
                    "normal" : normal,
                    "x" : tangentLine.direction}
            });
            
            var tool = qCreatedBy(id + "plane1", EntityType.BODY);
            
            debug(context, tool);
           
            opSplitPart(context, id + "splitPart1", {
                    "targets" : body,
                    "tool" : tool
            });    
            
        });
  • Alex_KempenAlex_Kempen Member Posts: 248 EDU
    Since this thread got bumped, I'll point out there are now specific queries for the default planes and origin, `qFrontPlane`, `qRightPlane`, `qTopPlane`, and `qOrigin`. Note these are queries to the physical construction planes/point in the graphics window. If you simply want the underlying data representation (e.g. a `Plane` object you can pass to `newSketchOnPlane`), you can use the constants `XY_PLANE`, `YZ_PLANE`, `XZ_PLANE`, `WORLD_ORIGIN`, and `WORLD_COORD_SYSTEM` directly.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • jnewth_onshapejnewth_onshape Member, Onshape Employees Posts: 89
    edited June 27
    Thanks for mentioning the new queries @Alex_Kempen
    You can peek at `defaultFeatures.fs` in the standard library to see them. In particular: `newSketchOnPlane` takes a plane object, but `newSketch` takes a query so you can use the queries like:

    const sketch = newSketch(context, id, {
     "sketchPlane" : qTopPlane(EntityType.FACE)
    });

Sign In or Register to comment.