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.

Simple Polyline Sketch Example on Selected Plane

thomas_allsupthomas_allsup Member, User Group Leader Posts: 4
I can't find a Featurescript example where the user picks the plane or face in the precondition area.  All the examples I find use the "TOP" but I want to select one of the datums or an existing face to create my canned polyline logo.  Help!

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
    You just need to query a planar face, like this:
            annotation { "Name" : "Plane", "Filter" : EntityType.FACE && GeometryType.PLANE, "MaxNumberOfPicks" : 1 }
            definition.plane is Query;

    Senior Director, Technical Services, EMEAI
  • thomas_allsupthomas_allsup Member, User Group Leader Posts: 4
    Yes - I got that part working.  I can select the various planes and faces of a cube.  My problem is the execution part, I put:

            var face = definition.face;  //in your example, this would have been "plane"
                   
            var sketch1 = newSketchOnPlane(context, id + "sketch1", {"sketchPlane" : face});   // if I change this "TOP" like all the examples, it will draw on the top plane 
                                    
            skPolyline(sketch1, "polyline1", {"points" : [vector( 0,  0) * inch, vector( 1, 1) * inch, vector( 2,0) * inch, vector( 0,  0) * inch]}); // drawing a simple triangle  - this is where I would put my logo or other shape
            
            skSolve(sketch1);
            
            opExtrude(context, id + "extrude", {"entities" : qSketchRegion(id+"sketch1") , "endBound" : BoundingType.BLIND,"endDepth" : 1 * inch });


    Thanks for the insights (I love the videos by the way and I have watched almost all of them).
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
            var face = evPlane(context, { "face" : definition.face }); // definition.face is a Query, not a plane
    
            var sketch1 = newSketchOnPlane(context, id + "sketch1", { "sketchPlane" : face });
    
            skPolyline(sketch1, "polyline1", { "points" : [vector(0, 0) * inch, vector(1, 1) * inch, vector(2, 0) * inch, vector(0, 0) * inch] });
    
            skSolve(sketch1);
    
            opExtrude(context, id + "extrude1", {
                        "entities" : qCreatedBy(id + "sketch1", EntityType.FACE),
                        "direction" : face.normal,
                        "endBound" : BoundingType.BLIND,
                        "endDepth" : 1 * inch
                    });

    Senior Director, Technical Services, EMEAI
  • thomas_allsupthomas_allsup Member, User Group Leader Posts: 4
    Wow - that fixed it and it makes complete sense.  I have to get queries straight.  THANKS!!!!

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    @NeilCooke @thomas_allsup

    The right thing to do here is to use `newSketch` rather than `newSketchOnPlane`.  The former takes a face query and the latter takes a mathematical definition of a plane.  If you use the former, you will not need to call `evPlane`.

    https://cad.onshape.com/FsDoc/library.html#newSketch-Context-Id-map
    https://cad.onshape.com/FsDoc/library.html#newSketchOnPlane-Context-Id-map
    Jake Rosenfeld - Modeling Team
Sign In or Register to comment.