Skip to content
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

feature request: allow specifying an "expression" to render as a command-line argument #18

Closed
justbuchanan opened this issue Oct 19, 2023 · 7 comments

Comments

@justbuchanan
Copy link
Member

I have a model designed in cadquery that is made up of multiple 3d-printed parts, each defined in their own python function. I'd like an easy way to export each of these individual parts as stl files.

I want to do something like this:

# model.py

def part1():
  return cq.Workplane("XY")...

def part2():
  return cq.Workplane("XY")...

def part3():
  return cq.Workplane("XY")...
# export just part1
cq-cli --codec stl --infile model.py --outfile part1.stl --expr "part1()"

# export all parts
for part in part1 part2 part3; do
  cq-cli --codec stl --infile model.py --outfile "$part.stl" --expr "$part()"
done
@jmwright
Copy link
Member

I have been considering adding something like an entrypoint argument to handle situations like this. I think the challenge is in getting this to work with CQGI. I may have to monkey-patch methods that don't call show_object, or I'll have to write a shim that imports the module somehow, involves the method, and then calls show_object on the result. All the ways I've thought of to do it are pretty messy.

@justbuchanan cq-cli should be installable via pip using git now, but I haven't updated the readme with the information. This allows cq-cli to integrate better with a Python environment.

@justbuchanan
Copy link
Member Author

Great, glad to hear this is something you've considered :). And thanks for the info on cqgi difficulties - if I have time, I may take a look at that and see what I can figure out.

Thanks for the tip on pip-installability.

@jmwright
Copy link
Member

@justbuchanan Feel free to register your interest on that PR. It wasn't actually a feature I needed, so when the PR discussion lasted longer than expected, I got distracted on other things. I looks like I just need to fix the test coverage to make that PR ready for merge.

@justbuchanan
Copy link
Member Author

Sounds good, would you mind linking the PR you're thinking of?

@jmwright
Copy link
Member

Sorry, I was posting everything on my phone and meant to put that message in the tuple PR discussion #17 CadQuery/cadquery#1373

@jmwright
Copy link
Member

@justbuchanan Feel free to add your ideas for making this work and/or submit a PR. It's going to be a while before I am able to get back to this.

@justbuchanan
Copy link
Member Author

This feature was implemented in #26 - closing the issue.

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

No branches or pull requests

2 participants