0

I am currently writing a python script to automate a structure made of cubes forming a 3D grid. The cubes are randomly placed and there are two types of cubes.

It is a single part but I plan to assign different regions to the two types of cubes. Therefore, I first need to select the necessary cubes. To do this I need to create a region. Since I know the positions of the centres of the cubes, I can find the necessary cubes by getting a list of the faces in the structure, computing their normals and then subtracting or adding half of a cube dimension (1.25 / 2) to find the centre. Then I check if this centre is in the list of positions. If it is, then I know the face belongs to that region.

The Abaqus Python API Docs say that '.pointOn' gives the centroid of a face. However, when I look at results, I have centroids at positions such as 0.4166. This doesn't make sense to me as a centroid of a square is half its length, so the smallest possible position for x,y,z should be 0.625.

Here is the code that handles that detection:

soft_cube_faces = []
    for face in part.faces:
        normal_direction = face.getNormal(face.pointOn[0])
        centre_position = (
            face.pointOn[0][0] + (-1 * normal_direction[0] * single_cube_length / 2),
            face.pointOn[0][1] + (-1 * normal_direction[1] * single_cube_length / 2),
            face.pointOn[0][2] + (-1 * normal_direction[2] * single_cube_length / 2)
        )
        if centre_position in soft_cube_positions:
            soft_cube_faces.append(face)

Any help would be greatly appreciated. Thank you :)

I tried the code above and I expected to get central positions of cubes.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.