Get lists of faces for sweeping or lofting. First and last shape can be a vertex.
(s: Sequence[Shape])
| 5255 | |
| 5256 | |
| 5257 | def _get_face_lists(s: Sequence[Shape]) -> list[list[Face | Vertex]]: |
| 5258 | """ |
| 5259 | Get lists of faces for sweeping or lofting. First and last shape can be a vertex. |
| 5260 | """ |
| 5261 | |
| 5262 | face_lists: list[list[Face | Vertex]] = [] |
| 5263 | |
| 5264 | ix_last = len(s) - 1 |
| 5265 | |
| 5266 | for i, el in enumerate(s): |
| 5267 | if i == 0: |
| 5268 | |
| 5269 | face_lists = [[f] for f in el.Faces()] |
| 5270 | |
| 5271 | # if no faces were detected, try vertices |
| 5272 | if not face_lists and not el.edges(): |
| 5273 | face_lists = [[v] for v in el.Vertices()] |
| 5274 | |
| 5275 | # if not faces and vertices were detected return an empty list |
| 5276 | if not face_lists: |
| 5277 | break |
| 5278 | |
| 5279 | elif i == ix_last: |
| 5280 | |
| 5281 | # try to add faces |
| 5282 | faces = el.Faces() |
| 5283 | |
| 5284 | if len(faces) == len(face_lists): |
| 5285 | for face_list, f in zip(face_lists, faces): |
| 5286 | face_list.append(f) |
| 5287 | else: |
| 5288 | for face_list, v in zip(face_lists, el.Vertices()): |
| 5289 | face_list.append(v) |
| 5290 | |
| 5291 | else: |
| 5292 | for face_list, f in zip(face_lists, el.Faces()): |
| 5293 | face_list.append(f) |
| 5294 | |
| 5295 | # check if the result makes sense - needed in loft to switch to wire mode |
| 5296 | if any( |
| 5297 | isinstance(el[0], Vertex) and isinstance(el[1], Vertex) for el in face_lists |
| 5298 | ): |
| 5299 | return [] |
| 5300 | |
| 5301 | return face_lists |
| 5302 | |
| 5303 | |
| 5304 | def _get_face_lists_strict(s: Sequence[Shape]) -> list[list[Face]]: |