Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Export Mesh Objects to STL Using Python #393

Open
glonor opened this issue Oct 5, 2024 · 2 comments
Open

How to Export Mesh Objects to STL Using Python #393

glonor opened this issue Oct 5, 2024 · 2 comments

Comments

@glonor
Copy link

glonor commented Oct 5, 2024

Hello,

I am using the Python bindings (version: 2.3.2) and trying to extract individual MeshObject instances from a 3MF file. The 3MF file contains multiple mesh objects within a single build, and my goal is to export each one of them into separate STL files.

Code Example:

from lib3mf import get_wrapper

file_path = "example.3mf"

wrapper = get_wrapper()
model = wrapper.CreateModel()

reader = model.QueryReader("3mf")
reader.ReadFromFile(file_path)

object_iterator = model.GetObjects()

while object_iterator.MoveNext():
    mesh_object = object_iterator.GetCurrentObject()
    if mesh_object.IsMeshObject():
        print(f"Mesh Object: {mesh_object.GetResourceID()}")
        # mesh_object.export()  # <--- Hypothetical function

Currently, I am manually iterating over each mesh’s vertices and faces using the GetVertex and GetTriangle methods. I was wondering if there is a more direct approach in lib3mf to export an individual MeshObject as an STL file.

Thank you!

@vijaiaeroastro
Copy link
Collaborator

@glonor The current architecture of lib3mf only allows calling writer on a model and not on individual mesh objects or components.

@glonor
Copy link
Author

glonor commented Oct 8, 2024

Thank you for the clarification! It would be a very useful feature to have the ability to export individual MeshObject instances directly, without needing any workarounds. I hope this is something planned for future updates, as it would greatly simplify the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants