CadQuery / cq-cli

Command Line Interface for executing CadQuery scripts and converting their output to another format.
Apache License 2.0
22 stars 7 forks source link

handle bytes and bytearray codec outputs in cq-cli.py #20

Closed justbuchanan closed 1 year ago

justbuchanan commented 1 year ago

I see that gltf was added very recently, so this is probably already on your radar. If you have another fix for this in progress, feel free to close this PR.

I see that in cadquery, gltf export of assemblies hardcodes binary=True here: https://github.com/CadQuery/cadquery/blob/f467ac95051a112eee3f3767532d9eb58d80e9d7/cadquery/assembly.py#L491, so the binary=False in cq_codec_gltf.py is ignored.

With binary output, a couple changes were needed in cq-cli.py to optionally open the output file in binary-writing mode.

I'm happy to update the tests if you're ok with this fix. Not sure if you were planning to modify cadquery to make binary gltf output optional.

jmwright commented 1 year ago

I've got a PR open on CadQuery to fix the hardcoded binary mode. https://github.com/CadQuery/cadquery/pull/1418

I was going to have to add binary support for gltf and STL anyway, so if you want to add it for gltf they would be great. I originally only had ASCII support because cq-cli can be used to pipe text between utilities (more of a Linux/Unix thing), but I don't think it makes sense to lock the utility to only ASCII because most people (myself included) just use cq-cli to generate output formats from a CadQuery source file.

justbuchanan commented 1 year ago

Awesome!

I'll drop the changes to the gltf codec since you've got that figured out. I do think some binary output formats will be useful, so maybe the changes I've made to handle bytes and bytearray codec outputs will still be of value. I've trimmed the PR down to just that and renamed it.

jmwright commented 1 year ago

Thanks @justbuchanan