#๐Ÿ”’ Trying to slice a stl file

4 messages ยท Page 1 of 1 (latest)

tawny oak
#

Im trying to slice a stl file using trimesh. In this case, Im trying to get a cross-section of a cube at the center (which should be a simple square)

## ... more code here

mesh = trimesh.load_mesh(stl_file)
sliced_mesh = mesh.section(<plane origin, normal and all that goes in here>) ## this is a trimesh.path.path.Path3D
cross_section = sliced_mesh.to_planar()[0] ## this is a trimesh.path.path.Path2D
cross_section = cross_section.simplify()

## ... more code here

now up until here, everything is fine but when I do this:
print(len(cross_section.entities))
it gives back 1. And this one entity is trimesh.path.entities.Line which is kind of weird because the cross-section is suppose to be a square, not a line.
But when I do this:
cross_section.show()
it shows me a square, which is correct, yet there is only one entity making that square... which is a line. How is this possible? And how can I extract all lines inside the cross_section correctly?

astral jayBOT
#

@tawny oak

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

astral jayBOT
#

@tawny oak

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.