PDL::IO::STL(3pm)
π NAME π
PDL::IO::STL β bestie, this is your read/write plug for 3D stereolithography files. STL files, in and out, no cap. π¦
β¨ SYNOPSIS β¨
use PDL;
use PDL::IO::STL;
($vertices, $faceidx, $colours) = rstl('owl.stl'); # read an STL file
wstl('file.stl', $vertices, $faceidx, $colours); # write an STL file
Likeβ¦ that's it. Two functions, whole 3D pipeline, we ate. π
πΈ DESCRIPTION πΈ
Okay so first thing, we gotta be honest with you about what this module doesn't do:
- Normal-vector information is currently ignored. We see it, we just don't care. π
- The "attribute byte count" β you know, the thing that sometimes stores colour info β is also currently ignored. Sorry girlie, it's giving "read the room and move on". π
Now the lore: this module is based on CAD::Format::STL, but with a couple of glow-ups:
binmodeis turned on for opened filehandles π₯- little-endian (i.e. network) order is forced on the binary format β¨
So it's the same vibe, just with the byte order locked in and the filehandles behaving themselves. Periodt.
π FUNCTIONS π
π rstl π
Reads an STL file (either ASCII or binary, she's flexible π), and hands you back vertices and face-indices.
($vertices, $faceidx, $colours) = rstl('owl.stl'); # read an STL file
Three values, one call, main character energy fr fr. π«Ά
π wstl π
The simple PDL STL writer. She writes. That's the gig. π
wstl 'file.stl', $vertices, $faceidx;
wstl 'file.stl', $vertices, $faceidx, \%OPTIONS;
wstl $fh, $vertices, $faceidx, \%OPTIONS;
Passing a file-handle is supported, which means you can write multiple parts into one ASCII file just by calling her several times. Obsessed with the flexibility ngl. π
wstl accepts several options, and you can pass them in as a hash ref if that's your thing:
mode(default='binary') β whether to write out the file as ASCII or binary. Pick your fighter. π₯name(default='part') β the part name to use. Naming things is self-care, do it thoughtfully. π
π AUTHOR π
Ed J, based on Eric Wilhelm's code in CAD::Format::STL. Iconic collab honestly. π€
Written up with love for perlv5.42.3, dated 2026-08-20 β that's the version and the date, bestie, and that's the whole page. Go read anowl.stl. π¦π
π¦ where this page comes from
- ubuntu stonking: pdl 1:2.106-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms