How to Read Colors in STEP Files
I would like to specify physical groups based on the colors of faces in an imported STEP file.
The idea is that I can specify boundary conditions in my CAD program by coloring faces and then exporting the geometry as a STEP file, which can then be read and meshed by gmsh.
The issues is I can't figure out how to get gmsh to read the colors off the face entities.
When I load a colored STEP file into the GUI the faces are not colored.
Also using the python sdk on gmsh 4.4.1 running:
import gmsh gmsh.initialize() gmsh.option.setNumber("General.Terminal", 1) gmsh.option.setNumber("Mesh.Algorithm", 3) # Frontal-Delaunay gmsh.option.setNumber("Geometry.OCCImportLabels", 1) # import colors from STEP fname = r'cubez.stp' #gmsh.merge(fname) gmsh.model.occ.importShapes(fname,format="step") gmsh.model.occ.synchronize() gmsh.model.mesh.generate(2) print([gmsh.model.getColor(*tag) for tag in gmsh.model.getEntities()]) print([gmsh.model.getEntityName(*tag) for tag in gmsh.model.getEntities()]) [gmsh.model.getColor(*tag) for tag in gmsh.model.getEntities()]
(0, 0, 255, 0) for all entities, rather than showing that 3 of the faces are red green and blue.
I'm not sure if gmsh.model.getColor() is actually the appropriate function to use though.
The test file, a cube with 3 faces colored: cubez.stp