Skip to content

Add binary option to stl codec#45

Merged
jmwright merged 1 commit intoCadQuery:mainfrom
Charlie-83:stl_codec_binary
Apr 14, 2026
Merged

Add binary option to stl codec#45
jmwright merged 1 commit intoCadQuery:mainfrom
Charlie-83:stl_codec_binary

Conversation

@Charlie-83
Copy link
Copy Markdown
Contributor

@Charlie-83 Charlie-83 commented Apr 12, 2026

Relevant issue: #29

I have added a binary option to the stl codec. This should be True or False

Default encoding is still ASCII for reasons discussed in the issue.

I have added a relevant test.

@Charlie-83 Charlie-83 force-pushed the stl_codec_binary branch 3 times, most recently from cd5a346 to a89ee51 Compare April 12, 2026 19:22
@jmwright
Copy link
Copy Markdown
Member

@Charlie-83 This test has a method of checking binary file content, in case it's relevant here.

https://github.com/CadQuery/cq-cli/blob/main/tests/test_glb_codec.py#L46

@Charlie-83
Copy link
Copy Markdown
Contributor Author

@jmwright Yeah, I did a very similar thing here. Just checking that the first 5 bytes aren't "solid" which would mean it was an ASCII stl. Wikipedia says that the binary format should never start with "solid".

Of course, the binary file could just be a load of nonsense. But, I'm guessing that actually parsing the contents to check it's cube is overkill. I could check that the number of triangles is correct or something since that's near the start of the file.

@jmwright
Copy link
Copy Markdown
Member

@Charlie-83 Is this ready for review?

@Charlie-83
Copy link
Copy Markdown
Contributor Author

@jmwright Yes, thanks

@jmwright
Copy link
Copy Markdown
Member

Thanks for this @Charlie-83 !

@jmwright jmwright merged commit 0461d0e into CadQuery:main Apr 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants