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.

Problem with opLoft and qUnion([qNthElement(......query

tonvistonvis Member Posts: 41 ✭✭
Can someone of the team please help me out ?

Working on a Bevelgear FS combining Neil Cooke's Spurgear and ika Hölsö's FS , I got problems with opLoft to use two teethprofiles  as edgequeries from qUnion([qNthElement( .......
Lofting whole sketches is no problem but  I just need a cut-outpart of the sketches:

/* 687
    var vertrices = qUnion([outer_modul, inner_modul]);
    var profileSubqueries = [qCreatedBy(id + "sketch5"), qCreatedBy(id + "sketch6")]; 

    opLoft(context, id + "loft1", {  //@opLoft: LOFT_VERTEX_ADDITIONS error
                "profileSubqueries" : profileSubqueries,
                "vertrices" : vertrices
            });
*/


I has tried everything. It may be very simple but I can't find a solution.
When working in partstudio it is no problem to loft the both faces.

May thanks for your help
tonvis






Best Answer

  • tonvistonvis Member Posts: 41 ✭✭
    Answer ✓
    I found the answer 



        //******************************forming teeth *********************************************
        /**  to get the teeth_faces out of all other faces, this is the right way to do it
         *   use qSketchRegion(id) and qUnion([qNthElement(faces, n)])
         *  I was using edges first, but that was the wrong way of doing
         *  with no result
         * */
        // -----------------solves all the faces to select from --------------------------

        var faces = qUnion([qSketchRegion(id + "sketch5"), qSketchRegion(id + "sketch6")]);
        //debug(context, faces); //debug: Query resolves to 2x6 faces


        // ----------------- get the teeth_faces  out of 6 faces -------------------------------
        //var faceQuery0 = qUnion([qNthElement(faces, 0)]);
        var faceQuery1 = qUnion([qNthElement(faces, 1)]); //2 x onder
        //var faceQuery2 = qUnion([qNthElement(faces, 2)]);
        //var faceQuery3 = qUnion([qNthElement(faces, 3)]);
        var faceQuery4 = qUnion([qNthElement(faces, 4)]); //2 x boven
        //var faceQuery5 = qUnion([qNthElement(faces, 5)]);
        //debug(context, faceQuery1);
        //debug(context, faceQuery4);

        /** no problem for loft any longer ! it was really hard  to find the solution */
        opLoft(context, id + "loft1", {
                    "profileSubqueries" : [faceQuery1, faceQuery4]
                });

    tonvis

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    You probably need to be more specific with your query: var profileSubqueries = [qCreatedBy(id + "sketch5"), qCreatedBy(id + "sketch6")]; 

    Sketches have edges, faces, vertices, bodies - which ones are you lofting?
    Senior Director, Technical Services, EMEAI
  • tonvistonvis Member Posts: 41 ✭✭
    Hello Neil,
    I am aware of your point but that is just my question . Featurescript is not  simple to make the right queries.
    On the sketch picture you see the corresponding cut-out for teeth, but I can't get hold on these faces,edges or bodies to obtain a loft
    What query do I need ?
    Thanks for your quick reaction
    tonvis
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    edited December 2019
    try:
    var profileSubqueries = [qCreatedBy(id + "sketch5", EntityType.FACE), qCreatedBy(id + "sketch6", EntityType.FACE)];

    Senior Director, Technical Services, EMEAI
  • tonvistonvis Member Posts: 41 ✭✭
    Neil,
    Thanks for your answer.

    I had tried this before and then I got this total sketch , but I need only loft a vew parts out of it.



    If I      // --------------------------------- delete unused edges ------------------------------------------
        opDeleteBodies(context, id + "deleteBodies1", {
                    "entities" : delete_edges
                });
    All will disapear and I get @opLoft: LOFT_SELECT_PROFILES error.

    I hope that you help me out with a solution toget  hold on  :

       var outer_modul = qUnion([ // 2x bottom edges
                edgeQuery_5,
                edgeQuery_6,
                edgeQuery_8,
                edgeQuery_10
            ]);
    and 
       var inner_modul = qUnion([ // 2x top edges
                edgeQuery_17,
                edgeQuery_16,
                edgeQuery_19,
                edgeQuery_21
            ]);

    They won't listen to me !


    tonvis
  • tonvistonvis Member Posts: 41 ✭✭
    Answer ✓
    I found the answer 



        //******************************forming teeth *********************************************
        /**  to get the teeth_faces out of all other faces, this is the right way to do it
         *   use qSketchRegion(id) and qUnion([qNthElement(faces, n)])
         *  I was using edges first, but that was the wrong way of doing
         *  with no result
         * */
        // -----------------solves all the faces to select from --------------------------

        var faces = qUnion([qSketchRegion(id + "sketch5"), qSketchRegion(id + "sketch6")]);
        //debug(context, faces); //debug: Query resolves to 2x6 faces


        // ----------------- get the teeth_faces  out of 6 faces -------------------------------
        //var faceQuery0 = qUnion([qNthElement(faces, 0)]);
        var faceQuery1 = qUnion([qNthElement(faces, 1)]); //2 x onder
        //var faceQuery2 = qUnion([qNthElement(faces, 2)]);
        //var faceQuery3 = qUnion([qNthElement(faces, 3)]);
        var faceQuery4 = qUnion([qNthElement(faces, 4)]); //2 x boven
        //var faceQuery5 = qUnion([qNthElement(faces, 5)]);
        //debug(context, faceQuery1);
        //debug(context, faceQuery4);

        /** no problem for loft any longer ! it was really hard  to find the solution */
        opLoft(context, id + "loft1", {
                    "profileSubqueries" : [faceQuery1, faceQuery4]
                });

    tonvis
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646
    edited January 2020
    @tonvis

    It's not really a great idea to rely on qNthElement().

    What I would do instead is something specific like:

    const face1 = qContainsPoint(qSketchRegion(id + "sketch5"), vector(1, 2, 3) * inch);
    const face2 = qContainsPoint(qSketchRegion(id + "sketch6"), vector(3, 2, 1) * inch);


    Replacing the position with an actual position that you know exists on that sketch face.
    Jake Rosenfeld - Modeling Team
Sign In or Register to comment.