Refactored Faster Rolodex Compatible Filament Swatches (OpenSCAD)
Obliczymy ostateczną cenę na podstawie wybranego pliku. Sprawdzisz ją i zaakceptujesz przed płatnością.
Zapisane na tym urządzeniu.
The same model as the source, refactored to render faster!
- Ocena
- 5 / 5
- Polubienia
- 20
- Pobrania
- 74
- Wydruki
- 1
- Wyświetlenia
- 642
- Oceny
- 1
Aktualizacja u źródła:
Informacje o modelu
- Źródło
- Printables
- Kategoria
- Accessories
- Licencja
- Creative Commons — Attribution
The filament swatch Rolodex by 3D Printy is a great idea! However, while printing a bunch of swatches, I found the file sometimes took minutes to render - which really slowed down my experimentation to find the right size and text for each swatch. So to learn some more SCAD and more deeply understand the model, I have done some significant code refactors on this file. This is a work in progress as I learn SCAD optimization techniques. There may be more performance gains in the future!
Initial load+preview(F5) times, on Windows 10 with OpenSCAD 2021.01 (YMMV), opened by double-clicking the .scad file:
- Original - Total rendering time: 0:00:00.445
- Refactored - Total rendering time: 0:00:00.340
Text change preview times, by adding a trailing ‘e’ to line 1 text and previewing:
- Original - Total rendering time: 0:00:00.298
- Refactored - Total rendering time: 0:00:00.352
Full render(F6) times after a fresh reload:
- Original - Total rendering time: 0:02:13.948
- Refactor - Total rendering time: 0:01:44.742
- Refactor + reduced $fn - Total rendering time: 0:00:41.564
In this version, you will find:
- All the same variables as in the base file! Just use whatever settings you had before. See the original for more info about what each does.
- Except: Text line positions are now lower case! Use
["left", "center"].
- Except: Text line positions are now lower case! Use
- The model renders flat, in printable orientation. Convenient for color-change slicing.
This file is licensed CC-Attribution, the same as the original file. Use it the same way you would have the original.
Refactor changelog:
- Render each object flat in the native X-Y plane, with origin at the bottom left. This removes a lot of
width/2calculations, and confusing Y and Z coordinates. Plus, it enables:- Final position is controlled by an outer
translatecall surrounding each object. - All dimensions while creating the shape are based on the [0,0,0] origin for convenience.
- Final position is controlled by an outer
- Render all shapes and text that go all the way through a card or spacer in 2D, then extrude that 2D shape to 3D all at one time.
- Generalize
filletfunction to round corners, generates a 2D negative round instead of removing cubes and re-adding cylinders in 3D. - Basic card shape and Rolodex hole generation code are shared between cards and spacers - so they will always be the same.
- De-duplicated code for ring and star holes - now there is only one location where these are created.
- Cleaned up the logic for combined flag uses quite a bit - when ring and star holes are applied, or when card and spacer are both rendered.
- Combined text generation by making
Line_x_Positionvariables take the same values as thehalignargument. Saved a bunch of code for relocating text, and each line is generated on exactly one line of code for easier modification. - Total line count reduced from 501 to 326 - with all the same flags and features. Much nicer to read
- Pre-render combined card shape before differencing with subtractive shapes. This reduces some of the math complexity in that difference calculation.
- Added some tiny additional margins for subtractive shapes, so fast previews don't show ghost surfaces.
- Reduced explicit
$fnused for extrusion to 32 - not a significant quality impact at Rolodex size. This has the biggest performance impact, but is not shipped by default - I printed with 100, and have not tested it yet. Control with theextrude_fnvariable at the top.
TODOs / investigations:
- Where might the
render()call give additional benefits? - More render optimization possible? Need to learn more!
This was an interesting exercise in learning OpenSCAD! I hope someone can learn from seeing two different code approaches to the exact same model.