How to set a color or label on an shape face? #813
-
For debugging purpose I would like to add a color and label to a shape face. Something like that: box = Box(4, 2, 1)
box.edges()[0].color = 'green'
box.edges()[0].label = 'back'
show_object(box) # show the box with one green face. And same for edge, vertex, etc. Is it possible ? edit: I managed to do this by directly displaying the faces: box = Box(4, 2, 1)
faces = list(box.faces())
faces[0].color = 'green'
faces[0].label = 'back'
show_object(faces) But Maybe there is a better approach? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As you might have surmised, build123d does not support having more than one color per object. I also regularly need functionality to "highlight" specific faces/edges/vertices but I approach it in a far less manual way using some of the features of OCP CAD Viewer. I have found that if the manual approach is too tedious then I simply avoid using it which negatively impacts my overall modeling productivity. from build123d import *
from ocp_vscode import *
set_port(3939)
show_clear()
set_defaults(ortho=True, default_edgecolor="#121212")
with BuildPart() as p:
Box(1,2,.5)
Box(.5,1,.5,mode=Mode.SUBTRACT)
someface = faces().sort_by(Axis.X)[-1]
set_colormap(ColorMap.seeded(colormap="rgb", alpha=1, seed_value="vscod"))
show_all(reset_camera=Camera.KEEP) The first key line is I personally use a VSCode snippet which provides a file template for build123d modeling as well as some shortcuts. My snippet is available here https://gist.github.com/jdegenstein/6233ac42632d9098c99da029fe0615c2 |
Beta Was this translation helpful? Give feedback.
As you might have surmised, build123d does not support having more than one color per object. I also regularly need functionality to "highlight" specific faces/edges/vertices but I approach it in a far less manual way using some of the features of OCP CAD Viewer. I have found that if the manual approach is too tedious then I simply avoid using it which negatively impacts my overall modeling productivity.