Skip to content

Filtering

A model consists of vertices, edges and faces. Once an object is created you often want to select one of those 3 building blocks.

Selecting one of those is done with a method of the object you created. These methods are:
* vertices()
* edges()
* faces()

arrayOfVertices = Testobject.vertices()
arrayOfEdges = Testobject.edges()
arrayOfFaces = Testobject.faces()

The method returns ALL vertices/edges/faces of the object is it used on.
As it is an array that is returned you can acess a specific item in the array with an array operation.

Testobject.faces()[0] # returns the first face in the array
Testobject.faces()[-1] # returns the last face in the array

Tip

Even if it might seem that there is an order to the returned list please note that this order can change randomly!

So to make sure you grab the right one you need to sort or order the list according to some rule. Methods to sort are:
.sort_by()

You also need something along which sort for example. This can be an axis.
The final code thus looks like this:

singleSpecificFace=Testobject.faces().sort_by(Axis.Z)[-1]

This will grab all faces of Testobject and sort them according to their place relative to the Z Axis and return the last face of the list.

Tip

Be aware that you need to be really specific. Ordering along the Z Axis for example can still return two equally distant faces which will be random on which one ist last!

So the real trick is to sort and select correctly.

Helpfull in orienting yourself is to visualize your grabed items. This can easily be done by plugging your array into the show method:

show(arrayOfFaces) # will show all faces you grabbed
show(arrayOf Faces,colors =["yellow"]) # will change the faces color to yellow

Examples (to be described)

select some edges on the extruded 20 degree trapezoid

edgs = faces().sort_by(Axis.Y)[0].edges().filter_by(Axis.Z)
fillet(edgs, 10)


# select some different edges to create the roundover
edgs = faces().group_by(Axis.Y)[-1].edges().filter_by(Axis.X)
fillet(edgs, 14.999)