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

Add align_z argument to pack() Method. #632

Merged
merged 5 commits into from
May 27, 2024

Conversation

roman-dvorak
Copy link
Contributor

@roman-dvorak roman-dvorak commented May 21, 2024

Hi,

I've added a new argument align_z to the pack() method. When you enable this, it aligns all objects to the same Z axis.

Motivation and Context

I made this change to help with preparing print plates for 3D printing (set of multiple 3D bodies). The current pack() method only arranges objects in the X and Y coordinates. With the new align_z option, it becomes much easier to prepare objects for printing without needing to adjust them by a slicer.

How Has This Been Tested?

I did some manual testing to make sure the objects align correctly in the Z axis. See following images:

Without z_align (default)
parts = [box, lid]
p = pack(parts, padding=5, align_z=False)
show(p, reset_camera=Camera.KEEP)

obrazek
obrazek

With z_align
parts = [box, lid]
p = pack(parts, padding=5, align_z=True)
show(p, reset_camera=Camera.KEEP)

obrazek

Thank you!

@gumyr
Copy link
Owner

gumyr commented May 26, 2024

The original implementation didn't have the complete docstring - would you add the following (or with any improvements you can think of) to the pack function?

    """Pack objects in a squarish area in Plane.XY.

    Args:
        objects (Collection[Shape]): objects to arrange
        padding (float): space between objects
        align_z (bool, optional): align shape bottoms to Plane.XY. Defaults to False.

    Returns:
        Collection[Shape]: rearranged objects
    """

Thanks for the submission!

@roman-dvorak
Copy link
Contributor Author

Thanks for the comment. I added it as you wrote it, I have no problem with it and it is correct. Thanks for the help.

I would also like to expand the documentation because the mention of pack function is quite hidden in between 'tips'. I would probably look for such information in the 'assemblies' section. So I would do that in a separate page and additional PR. Do you have any suggestions on where to place it in the documentation?

@gumyr gumyr merged commit af4e729 into gumyr:dev May 27, 2024
11 checks passed
@gumyr
Copy link
Owner

gumyr commented May 27, 2024

Knowing where folks look for stuff is on of the difficult parts of writing good documentation so if you think you'd look in Assemblies I'm okay with that. Maybe a reference in the 3D exporters section would be helpful as well if the next step is to 3D print their objects?

I've merged the PR - thanks again!

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