Skip to content

Support for materials #1815

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

adrianschneider94
Copy link

Implemented material support.
In this approach, materials are stored in python dataclasses, the OpenCascade objects are only created when building the assembly.
Tests/docs are missing at the moment.

@shimwell
Copy link
Contributor

This looks great, I wonder if there is ever a use case for a material to be a string in as an option in addition to these nice material classes you have here. I was wondering if something like this would be possible / useful

assy = cq.Assembly()
assy.add(cube, name="red_cube", material="steel")

@adam-urbanczyk
Copy link
Member

@shimwell it would certainly be nice to have some predefined materials, and maybe allow to use the material name for other things too. But let's start with making CI green.

Copy link

codecov bot commented Apr 17, 2025

Codecov Report

Attention: Patch coverage is 96.44128% with 10 lines in your changes missing coverage. Please review.

Project coverage is 95.54%. Comparing base (8c68faa) to head (0f8b1d7).

Files with missing lines Patch % Lines
cadquery/materials.py 95.20% 4 Missing and 4 partials ⚠️
cadquery/occ_impl/assembly.py 97.26% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #1815    +/-   ##
========================================
  Coverage   95.54%   95.54%            
========================================
  Files          28       29     +1     
  Lines        7319     7502   +183     
  Branches     1102     1131    +29     
========================================
+ Hits         6993     7168   +175     
- Misses        195      199     +4     
- Partials      131      135     +4     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adrianschneider94
Copy link
Author

Material support in step exporting will get better in OCCT:
Open-Cascade-SAS/OCCT#447

@adrianschneider94
Copy link
Author

adrianschneider94 commented Apr 18, 2025

This looks great, I wonder if there is ever a use case for a material to be a string in as an option in addition to these nice material classes you have here. I was wondering if something like this would be possible / useful


assy = cq.Assembly()

assy.add(cube, name="red_cube", material="steel")

Would probably nice to have a set of materials to get started, but I think, any real-world application will require custom material sets.
Maybe there's another solution and we can find an existing material repository that can be utilized.

(edit: for example https://physicallybased.info)

@adrianschneider94
Copy link
Author

VRML export runs, but is not correct yet.

@adrianschneider94 adrianschneider94 marked this pull request as draft April 20, 2025 08:41
@adrianschneider94 adrianschneider94 force-pushed the materials-new branch 7 times, most recently from 9bad718 to a76304a Compare April 25, 2025 17:05
@adrianschneider94 adrianschneider94 marked this pull request as ready for review April 25, 2025 17:58
@adrianschneider94 adrianschneider94 force-pushed the materials-new branch 2 times, most recently from c068f78 to 892f001 Compare April 27, 2025 08:40
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.

3 participants