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

export to STL format capability added #176

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

export to STL format capability added #176

wants to merge 4 commits into from

Conversation

davidsosa
Copy link
Collaborator

I added the option to export geometry files in STL format for both magnets and in-vessel components.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this useful addition @davidsosa. I've recommended that we implement it as a single function that exports either STEP or STL since they are identical functions. There may be an argument to keep both export_step and export_stl, but have them each call the same function that performs the work with an optional file type.

@@ -309,6 +309,23 @@ def export_step(self, export_dir=""):
)
cq.exporters.export(component, str(export_path))

def export_stl(self, export_dir=""):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is functionally identical to export_step it might be better to rename export_step as export_standard (or something) and add the export type as an argument.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could change export_step to export_cad and have the function take the file extension as an argument (in string format)

@@ -269,6 +269,29 @@ def export_step(self, step_filename="magnet_set", export_dir=""):
)
cq.exporters.export(coil_set, str(export_path))

def export_stl(self, stl_filename="magnet_set", export_dir=""):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above about extending the previous method rather than copy/pasting to a new method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I did this way because It was usefull for me to get these two format at the same time, but for sure it can be done extending the method instead of duplicating it. I'l have a deeper look on it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could still get both in the same run, by just calling the method twice with different arguments.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Do we currently test this for STEP? Should we add a test for STL?

Copy link
Collaborator

@connoramoreno connoramoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some general comments and thoughts on naming and inputs that could possibly use some discussion. We'll also need to update the test suite to reflect the modified API.

Comment on lines +302 to +303
def export_components(self, filetype="step", export_dir=""):
"""Export CAD solids as STEP or STL files via CadQuery.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to include some kind of check on filetype input, unless we want to rely on CadQuery to issue an error if an incorrect filetype is supplied.

Comment on lines +253 to +255
def export_components(
self, filetype="step", filename="magnet_set", export_dir=""
):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to combine filename and filetype into a single input argument? This would deviate from our established convention.

@@ -250,23 +250,29 @@ def import_step_cubit(self):

self.volume_ids = list(range(first_vol_id, last_vol_id + 1))

def export_step(self, step_filename="magnet_set", export_dir=""):
"""Export CAD solids as a STEP file via CadQuery.
def export_components(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling this export_components, since there's only one component being exported, maybe we should call this something like export_cad, and do the same with the in-vessel build for consistency.

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.

3 participants