Open adrianschneider94 opened 3 months ago
This would be interesting. What is your main use case?
One is mass calculation, where the density is necessary. The other is, that you can export with the visualization settings, for example you can visualize metal nicely with gltf.
I'm also interested in this. Maybe it's also possible to add textures? My main case is that I'm creating a structure and want to create an (rendered, would it be possible?) image of it to be added to a printed document. Also the 3D model is exported for visualization in a viewer.
This would be very useful for calculating load!
@Jopie01 Textures should be possible, XCAFDoc_VisMaterialPBR has fields for that, but I don't know yet how those work.
Alright, let's give it a try @adrianschneider94 ! I did take a look at your branch and AFAICT you did some reformatting/reordering of imports. I will kindly ask to revert this. Our README contains instructions regarding which black version to use. Please do not apply other formatting fixes.
Regarding the PR I see the following tasks. First two are MVP, the rest would be nice to have but can ba via other PRs.
cq.Material
Yes, so far I have not set up everything, just got everything working for my project.
Some points:
I adapted the approach to keep all data in OCP objects using 'wrapped' attributes. But as for example XCAFDoc_VisMaterial.PbrMaterial()
won't return a ref but a copy of the struct, I now think it's easier to define a python class holding the material properties and then apply them in toCAF()
. What do you think about that?
Exporting STEP and GLTF works out of the box (the other formats too I guess), but as far as I know, STEP does not have material properties, it will just take the base color as color.
Regarding serialization: Is there already some approach in the library to serialization yet? I haven't seen it yet and even started to write own wrappers using pydantic. Would be great if that's already implemented.
[I updated your comment with numbers to be able to refert to the points]
[I updated your comment with numbers to be able to refer to the points]
Alright, here are my answers
Long story short, I’d propose to keep the scope small and for now “just” implement materials up to the CAF part.
As far as I can see, it's only possible to add colors so far. That could be extended to handling materials by using
XCAFDoc_Material
for physical properties andXCAFDoc_VisMaterial
for visualization.I implemented a first working approach: https://github.com/sangl-spezialtransformatoren/cadquery/tree/materials
The syntax is at the moment:
I wanted to use this issue as a discussion entrypoint, a pull request could follow later.
Links to OCCT documentation: