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.

Splitting a wing into ribs on iterations.

darren_13darren_13 Member, Developers Posts: 119 PRO
Im not getting any errors but also not getting any results, the idea is to split a wing into ribs and delete the bits in between, however user can specify rib number and thickness etc...

var halfrib=Ribthick/2;
        
        for (var i = intervals; i < Length; i += intervals)//outerloop for each rib
        {
            for (var j = -1; j == 1; j += 2)//inner loop for either side of rib
            {
                
                cPlane(context, id + i + j + "cplane1", { 
                    "entities" : qUnion(qCreatedBy(definition.selectPlane,EntityType.FACE)), 
                    "cplaneType" : CPlaneType.OFFSET, 
                    "offset" : (i+j*halfrib)*meter, 
                    "angle" : 0.0 * degree, 
                    "oppositeDirection" : false, 
                    "flipAlignment" : false, 
                    "width" : 0.15 * meter, 
                    "height" : 0.15 * meter });
                
                    
                splitPart(context, id + i + j + "split1", { 
                    "splitType" : SplitType.PART, 
                    "targets" : qUnion(qCreatedBy(id + "Loft1", EntityType.BODY)), 
                    "tool" : id + i + j + "cplane1", 
                    "keepTools" : false, 
                    "faceTargets" : qUnion([]), 
                    "faceTools" : qUnion([]) });
                
            }
        
        }

Is there a code error or is it possible the plane isn't intersecting the wing?

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    Hi Darren, I would recommend using the "op" functions directly where possible - use opSplit if you can. In your example above "tool" should be a query so use qCreatedBy.
    Senior Director, Technical Services, EMEAI
  • darren_13darren_13 Member, Developers Posts: 119 PRO
    Ok I did that but same results, is there an 'op' equivalent of cplane I should use that allows me to offset? alternatively I could just use the normal I have and use that to define a position but how would I call that in created by?

    something like:

    plane1=plane(normal*i+j*halfrib,normal)

    qunion(qcreatedby(plane1, EntityType.FACE) but plane1 wouldn't change name on each iteration?

    code now reads:

    var halfrib=Ribthick/2;
            
            for (var i = intervals; i < Length; i += intervals)//outerloop for each rib
            {
                for (var j = -1; j == 1; j += 2)//inner loop for either side of rib
                {
                    
                    cPlane(context, id + i + j + "cplane1", { 
                        "entities" : qUnion(qCreatedBy(definition.selectPlane,EntityType.FACE)), 
                        "cplaneType" : CPlaneType.OFFSET, 
                        "offset" : (i+j*halfrib)*meter, 
                        "angle" : 0.0 * degree, 
                        "oppositeDirection" : false, 
                        "flipAlignment" : false, 
                        "width" : 0.15 * meter, 
                        "height" : 0.15 * meter });
                    
                    opSplitPart(context, id + i + j + "splitPart1", {
                            "targets" : qUnion(qCreatedBy(id + "Loft1", EntityType.BODY)),
                            "tool" : qUnion(qCreatedBy(id + i + j + "cplane1", EntityType.BODY))
                    });
                    
                }
            
            }

    I really do appreciate the help, Darren.
  • lemon1324lemon1324 Member, Developers Posts: 225 EDU
    Given that the ribs are all at the same angle, it might be easier to use boolean subtraction:

    For each gap between the ribs, generate a rectangular prism that touches each rib face, and is longer than the wing an at least through the full thickness. Then, in a single boolean subtraction, choose all of these prisms as your tools, and the wing as the target.  Similar code is in the Box Joint or Laser Joint examples in the community showcase.
    Arul Suresh
    PhD, Mechanical Engineering, Stanford University
Sign In or Register to comment.