How to fold/unfold a carton box in Grasshopper?

I would like to know if there is a way to fold this kind of carton box layout back to its boxy shape.
If yes, what way would that be?
Crane is meant for origami folding, so I cannot individually control every angle. K2’s folding is only for tri-mesh, I guess.

1 Like

I did it manually, just rotate3d x 100 times, but I do hope I can do it with GH, so I can control every angle.

Interesting this came up - a LONG time ago, I used Strata 3D, which (at that time) came with packaging-specific features.

I’ve done a lot of packaging and dielines, and I’m surprised there aren’t more dedicated add-ons/apps for this kind of stuff.

Hmmm… maybe what you’re showing here can be done manually but animated and keyframed so that you can fold/unfold the box…

I have to try that now :wink:

1 Like

If you combine brep topology with chained transformations, you should be able to solve this in 1 go.
Otherwise I think kangaroo can indeed handle this.

What is the initial data?
Do you have some vector information?

1 Like

The original .ai file.
box_final.ai (422.0 KB)
I made the .ai file into surfaces.
surfaces.gh (41.9 KB)

1 Like

So… for the topology + shortest walk = chained transformations:
(you’ll need Shortest Walk Gh | Food4Rhino plugin)
ezgif.com-optimize


(you can change the static face index, but that require also you to flip some folding line…)
boxing.3dm (617.2 KB)
boxing.gh (21.3 KB)

Note how the polysurface have some congruent edge not joined (like near cursor)
2023-10-26 01_52_05-boxing.3dm (609 KB) - Rhino 7 Commerciale

16 Likes

Wow, this is a great method! Thank you very much!

2 Likes

3 Likes

And by adding a little script you could get that
ezgif-3-c65cbe65db
boxin_LDg.gh (19.6 KB)

  private void RunScript(double time, int nBranches, ref object dt_times)
  {

    DataTree<double> times = new DataTree<double>();

    for (int i = 0; i < nBranches; i++)
    {
      if (time < (double) i)
      {
        times.Add(0.0, new GH_Path(i));

      }
      else
      {
        if (time > (double) (i + 1))
        {
          times.Add(1, new GH_Path(i));
        }
        else
        {
          times.Add(time - (double) i, new GH_Path(i));
        }

      }
    }
    dt_times = times;
  }
8 Likes

Thank you! @laurent_delrieu

#Reinventingthewheel



boxing2.3dm (2.5 MB)
boxing2.gh (33.6 KB)

17 Likes

Not specific to folding, but a few years back when I was making some animations of sequential movements (rather than ones that all happen simultaneously), I got tired of having to animate multiple sliders then stitch the results together, so I made this little helper script, which I can’t remember if I shared before:
multivalue_animate_helper.gh (16.0 KB)

It lets you use a single slider to control multiple number variables, defining each one by start and end value, and the start and end frame. It then interpolates each value over that range during those frames.

I also added some easing functions, because abrupt starts and stops can look a bit too choppy.
For comparison here’s the same sequence with linear interpolation, cubic easing and bouncing:

boxfoldNone_00000

boxfoldSmooth_00000

boxfoldBounce_00000

For sure it’s not as user friendly a UI as a proper timeline keyframe/interpolation curve editor, but I find it a bit less cumbersome than animating lots of sliders separately.

10 Likes

Hi Daniel, your recent files show this message when opening:

Not sure what it is about. I usually copy paste the content to a new file.

Thanks for pointing this out, I’m not sure why it’s happening. I do have ShapeDiver installed, but I’ve not used it or any components from it in any of these files.
@mathieu1 do you know what causes this and how it can be avoided?

I am not sure what could be causing this, but if you close the pop-up and open the file it should work, and not happen again after saving it. This might be happening because of an issue in an old version of the ShapeDiver plugin, if Daniel updates to the latest version using the package manager, this should not be the case anymore.

2 Likes

It happens to me as well on Mac… even though I didn’t use any SD component…
It is just stressing my clients who get the code… (:

This one shouldn’t give any shapediver related messages
multivalue_animate_helper2.gh (17.1 KB)

3 Likes

@mathieu1 It seems to persist in this version.
SharedScreenshot

Thank you for reporting this, I will file this as a bug for our team.

1 Like