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

Fix 3MF color export and partial support for color import #594

Merged
merged 6 commits into from
Mar 18, 2024

Conversation

jdegenstein
Copy link
Collaborator

This PR reworks the current 3MF color export and color import to use material groups rather than the current approach of vertex specific colors. This PR allows for one to export objects from build123d with a color to a 3MF and then re-import that 3MF file with color preserved.

Known Limitations:

  • Removes vertex coloring from current implementation
  • Does not currently support 3MF color groups, which may be possible to support
  • One color per object
from build123d import *
a=Solid.make_box(1,2,3)
b=Solid.make_box(3,3,1)
a.color = Color(0.137, 0.306, 0.439)  # Tealish
b.color = Color(0.980, 0.973, 0.749)  # Goldish
exporter = Mesher(unit=Unit.CM)
exporter.add_shape([a,b])
exporter.write("ab_dual_color.3mf")

And importing:

importer = Mesher()
objects = importer.read("ab_dual_color.3mf")

Which can then be shown e.g. show(objects)
image

Copy link

codecov bot commented Mar 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.98%. Comparing base (e4ce1d8) to head (1c3f895).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #594   +/-   ##
=======================================
  Coverage   94.98%   94.98%           
=======================================
  Files          25       25           
  Lines        7999     7984   -15     
=======================================
- Hits         7598     7584   -14     
+ Misses        401      400    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jdegenstein jdegenstein marked this pull request as ready for review March 18, 2024 21:39
@jdegenstein jdegenstein merged commit 3def3c7 into gumyr:dev Mar 18, 2024
13 checks passed
@jdegenstein jdegenstein deleted the 3mf_color_fix branch March 19, 2024 01:31
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

Successfully merging this pull request may close these issues.

1 participant