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.

Adding texture by iterating through all faces in a part

j_j406j_j406 Member Posts: 6
Hi, I am working on a  feature script for surface texture generation and ran into an issue with iterating through all faces of a part.
It is a three step process
1. Split all faces along Z axis - works fine
2. Split all faces along X axis - works fine
3. Iterate through all faces and apply a random move using opMoveFace(...) - this does not work as expected. My current implementation does not iterate through all faces

 for (var aFace in qOwnedByBody(definition.partToCut, EntityType.FACE))
        {
            i=i+1;
            println(aFace);
            println("------------------------");
            
            
            /*opMoveFace(context, id + i+"moveFace", {
                    "moveFaces" : qOwnedByBody(definition.partToCut, EntityType.FACE),
                    "transform" : transform(vector(rnd2(), 0, 0) * millimeter)
            });*/

        }


Can you advice what the problem might be?



Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 3,550
    edited December 2020
    In the for loop definition you need to evaluate the query. Then use aFace in “moveFaces”
    Director, Technical Services, EMEAI
  • j_j406j_j406 Member Posts: 6
    Hi Neil, thanks for the feedback. Would you be able to tweak the code I posted? That's my first feature script. Not quite sure what query evaluation is.

  • j_j406j_j406 Member Posts: 6
    I think I got it
     var allfaces = evaluateQuery(context, qOwnedByBody(definition.partToCut, EntityType.FACE));
            for (var aFace in allfaces)
    {
    .
    .
    .
    .
    }



Sign In or Register to comment.