-
Notifications
You must be signed in to change notification settings - Fork 24
many, many changes for inline colors and other things #39
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
base: main
Are you sure you want to change the base?
Conversation
This is useful not only for better visualizing, but it can help with selecting things when importing into a slicer or other tool for further manipulation. For example, if you create a STEP file and convert it to a OBJ file (with any convenient converter tool), you can add the OBJ file to Bambu Studio, at which point Bambu Studio prompts you to map the colors in the OBJ file to filament colors. (Unfortunately, Bambu Studio doesn't preserve colors on STL, STEP, nor 3MF files at the moment. Maybe someday.)
adds a sketch for T-slot nuts
implement overall scale factors for when you need a little nudge to m…
…respectively This is useful not only for better visualizing, but it can help with selecting things when importing into a slicer or other tool for further manipulation. For example, if you create a STEP file and convert it to a OBJ file (with any convenient converter tool), you can add the OBJ file to Bambu Studio, at which point Bambu Studio prompts you to map the colors in the OBJ file to filament colors. (Unfortunately, Bambu Studio doesn't preserve colors on STL, STEP, nor 3MF files at the moment. Maybe someday.) Partial help for issue ndevenish#19 Solution for issue #9 I discovered that this online STEP converter creates 3MF files that Bambu Studio likes (and preserves colors if the STEP file has them): https://convert3d.org/step-to-3mf/app A workflow could be: - create STEP file via gflabel, either with the default colors or your own choices for base color and label color - use that converter to convert the STEP file to 3MF - add the 3MF into Bambu Studio; you'll see the colors in the prepare tab - slice the plate - when you print the plate, Bambu studio will try to pick filaments for each color, but you can also pick whichever filaments you prefer before actually sending it to the printer This workflow is less tedious than splitting the model to parts or objects and assigning filaments manually. ----------------- (Sorry about the extra commits on this branch and PR. I had a few independent changes in separate branches and accidentally combined all of them into this branch. I took the shortest path get thingws back to where they should have been.)
You can change colors with a label. See COLOR_NOTES.md for details. In this implementation, the colors are tracked "on the side" (that is, outside of the build123d hierarchy. As far as I have been able to figure out, build123d "forgets" the colors as the sketches are built up. The original top-level "label_sketch" is still created, but it's not used for output file export or for VScode rendering. Instead, the on-the-side bookkeeping is used. Perhaps someday we'll be able to track the colors directly in the build123d hierarchy, at which point the on-the-side bookkeeping can be dropped.
Add images for examples
cut/paste glitch
The new fragment type ColorFragment ({color(red)}) is introduced. It
changes the color of subsequent fragments until the end of the line or
another ColorFragment is seen. Exported STEP and SVG files, and VScode
renders preserve those colorings (though there is a new --svg-mono
command line option to preserve the old behavior).
A couple of changes as a side effect of implementing the above:
1. (fairly major) Labels are now created as a hierarchy of
Compound objects instead of sketches. Things are labelled at
each level, so hypotherically a tool looking at a STEP, STL, or SVG
could navigate through the layers. (My experiments find little
support fot his in those other tools, though FreeCAD seems to grok
it pretty well.)
2. (minor) ModifierFragment is a subclass of Fragment, meant
for things like the ColorFragment class. These things act on
other fragments instead of being rendered themselves.
allow inline color changes
Colored fragments
The previous x/y/z scaling options were easily implemented. Just
call a single build123d scale operation on the overall assembly.
Unfortunately, build123d considers that a "CAD operation" and so
creates all new objects in the assembly, losing the label and
color attributes in the process.
This revised implementation takes a different approach. It pre-scales
the dimensions of the base (including margin) as well as any command
line specs of width, height, depth, and margin. The excellent
existing dynamic scaling of the gflabel code takes care of everything
else.
Note: If you use label divisions ({|}) with scaling, you may get
some surprises. Each division is scaled and rendered independently.
That was always the case, but x/y scaling can make it more obvious.
My advice is to use trial and error to get what you want.
Scaling with colors and labels
Do you know such tools? I spent a little time trying to work out how to export 3mf with the right tags to have colouring pre-selected, but basically hit all kinds of dead-ends with the format being very loose.. |
It's challenging, but I found that FreeCAD keeps the colors in a STEP file. I also found that the web site convert3d.org does a good job of converting a STEP file to an OBJ or a 3MF. For both of those converted files, Bambu Studio notices the colors when you open them. (Which it doesn't do for a 3MF file from most other places or from the original STEP file. I don't know the details of that, but I guess the people at convert3d.org do and add whatever special sauce to make it work.) |
For inline scaling along any of the 3 axes. See SCALE_AND_OFFSET_NOTES.md for details.
Inline scaling and offsets
It seems that BambuStudio v2.5.0 introduced
|
That is pretty great news. I was looking around for a color 3MF that wasn't produced by Bambu Studio, but didn't come across one before my patience ran out. Have you had a chance to try it with a non-BBS color 3MF?
It looks like it's a bit more involved than just calling |
|
Sadly I have not tried any of the new features regarding 3mf. I think the best way forward is to implement 3mf exporting in gflabel and then try to import it. If I get around to implementing it I will pr the changes to your repo. |
These key-=value arguments are more intuitive than the previous
pairwise arguments. Example: {scale(x=2, y=0.5)}.
Text fragments are normally rendered as a single build123d Part. With this option, build123d still creates the single Sketch, but the resulting Faces are extruded to Parts individually. They are given Part labels that might make them easier to select in an external tool. The process of affiliating a character of the text fragment with a particular Face is not exact because some characters can render into multiple Faces, and the space character renders into no Faces. The Faces still get Part labels, but they may be less helpful or even confusing in some edge cases. The reason to let build123d create the Sketch of the entire text fragment is so that it does proper font spacing and other tricks. A more complete technique for the --text-as-parts option would render each character to a Sketch individually in order to count the Faces for that character. Then use that info to label the Parts. There's still no guarantee that build123d will return a Sketch with the Faces in character order. (In fact, we have observed that for some reason the first face corresponds last. We take that into account, but if that last character produced multiple Faces, we'd still be wrong in our workaround.)
Introduces --text-as-parts
|
@wjcarpenter I just got a basic version of the colored 3mf export working. Created a PR here: github.com/wjcarpenter/pull/14/ |
The type hint for the render() function is changed from Sketch to Compound. (Compound is the superclass of Sketch.) A fragment can continue to return the simple sketch, or it can return a Compound with children. If there are children, each should be a 2D shape of some kind, and each is extruded to a Part separately. If the children have color or label attributes, they are respected. The implementation of --text-as-parts is moved into the TextFragment render() function and returns a Compound with children, each with its own label.
Colored 3mf export using lib3mf
Svg fragment

Introduces fragment
{color(green)}to be able to make color changes within a label spec. See COLOR_NOTES.md for details and examples. The ColorFragment class is a subclass of ModifierFragment. A ModifierFragment is not itself rendered in any way. Instead, it modifies the rendering of fragments that follow it on a line.CAD labels are applied to all nodes in the CAD model hierarchy. Unnecessary nodes (those with only a single child) are squeezed out of the model. The idea is to allow precise and meaningful selection in outside tools that can deal with CAD model assemblies.
Coloring and CAD model labels are exported in STEP files, SVG files, and VSCode viewing. There is a command line option to do SVG in monochrome.
Reworks the software layering to extrude Parts at the lowest level instead of at the highest level.
Re-implements the command line scaling options in a way that preserves in a way that preserves colors and CAD model labels.
Many other small changes.