Adding Unique Text To Sides Of A Box? (Labelling Geometry)

Hi All,

I’ve resorted to asking the forum again for help on something I’m having trouble doing. I essentially have a box that’s made up of 6 individual sides (18mm panels that notch together) that are closed breps. I am trying to add some text and label each side - i.e - the front will be labelled ‘front’, the top ‘top’, side ‘L & R’ etc. As well as these labels beginning with a name ‘Box 02’ for example, which will be followed by the text so the front will say - ‘Box_02 - Front’. This is because i want to produce many boxes that each have unique numbers in sequence. I imagine having the option to change what number box it is - and it automatically changing in front of the labels.

I’m using a NGon text plugin as these components will be set for CNC. I can only seem to place the text manually on each face and have been struggling to join text and make this somewhat automatic.
any advice is appreciated.


Box Generator (584.7 KB)


Is this any help? Forum image server appears to be down at the moment?

P.S. I got a look at your geometry and belatedly realized that it’s not just a six-sided box. Each face is a tabbed polysurface.

I see that too and have informed the relevant parties.

Thanks for the reply Joseph,

I’m very new to grasshopper and so I still have a lot to learn. I’ve tried going about deconstructing the breps to then use evaluate surface but seen as they are tabbed and have so many surfaces I’ve filtered the largest one by area as the largest area will always be the surface I’m adding the labels onto. only thing is, there’s two of these largest areas per side so it’s even tricker and I’m unsure how to highlight just the outside surface?

I’ll take a look at what you’ve sent to see if I can pull anything from it.

I apologise if my terminology is incorrect or for any clueless mistakes in the definition.

I could tell. :wink: Cleaning up your GH code will make it easier for you and anyone trying to help you, such as disabling preview on all upstream components.

I didn’t try to understand all of your code (what are all those plugins doing for you?), but wrote this white group using my SrfDir cluster to isolate each polysurface along with a point on the face where you want the label. Proximity to that point will help you isolate the outward faces.

Box Generator (45.4 KB)

Here is what’s inside the psFace cluster:

Box Generator _2021Oct07a2

In theory, this should work with a data tree of these boxes, one box with six polysurfaces per branch, but I didn’t test it because you didn’t provide multiple copies. I could make copies of this one box by moving it around arbitrarily, then make a data tree with all the copies, but that’s work! :sunglasses:

P.S. The Bounding Box assumes your boxes are square with the ‘World XY’ plane and might break if you rotate them?

haha, thank you for this, it looks promising, I’ll take a look when I’m at the pc. As for the plugins, I think I’ve just seen many other posts offer solutions that involve these plugins and so I’ve tried them out. I’ll remove those I don’t need though, I’d prefer to rely mostly on GH components.

Most of this code seems to work fine without the plugins, with only one exception; code related to “add central fin if over 600mm” generates a null value.

I added the cyan group to make copies of the box and confirm that it works with a data tree.

Box Generator (54.0 KB)

This might be getting carried away… I replaced the ‘ptFace’ output of the psFace cluster with a ‘TF(Tag Frame) plane that is used by the Text Tag 3D component.

Box Generator (57.9 KB)

Inside the psFace cluster:

Box Generator _2021Oct07c2

Normally I avoid so much copy/paste and use data trees more but there it is enough going on here already for a beginner, eh?

Thanks for the time you’ve spent on this Joseph. The ‘add central fin if over 600mm’ is added when the slider for ‘width’ of the box is over 600mm. It moves one of the sides to the centre and so this will also be labelled.

I need to learn more about data trees. In V1 of this definition I relied on ‘list item’, and repeated that component for extracting each individual item. (I never realised you could add multi line text into a panel to list numerous items) :sweat_smile:

This response is encouraging and I’m eager to work with it. One last thing that you or others on the forum might be able to help with - is there a way to have a separate section of text to give each box a number? this would be in front of the labels added - i.e. Box 01_Front. This is so, if many of these boxes are generated at different sizes and there sides are separated you would be able to see what sides belong to which box.

Yes, you won’t really know GH without understanding data trees.

Sure. I modified the psFace cluster again, adding an ‘L’ (Label) input and output. Internally, the tree branch path is used as the box number.

Box Generator (58.3 KB)

You can, of course, change the labels to Front, Back, Left and Right.

Inside the psFace cluster:

Well, this is a bridge too far in some ways. But please bear with me.

Until now, I’ve been using faces of the Bounding Box to get the ‘TF’ (Tag Frame) at the Area centroid, which is the location and orientation (Plane) for the Text Tag 3D. I decided that maybe you want the outer face of each side’s polysurface instead so modified the psFace cluster again to use and return that as the cluster’s ‘F’ output. The polysurface is still available as the ‘S’ output.

Whether or not this was a good idea, I don’t know? The obvious change is that tags are not oriented as they were before. Some are rotated 90 degrees, some 180 degrees (upside down!). This is due to how your notched panels were created. Likely not as consistent as Bounding Box faces.

So I glanced at some of your code that creates the box with notched sides and noticed a few things, unrelated to face orientation.

  • The Join after SDiff does nothing and is useless.
  • It doesn’t make sense to wire the ‘South’ and ‘North’ sides to the SDiff ‘A’ input since they are already notched and also wired to the ‘B’ input.
  • For clarity, I copied the SDiff so I could get ‘Top’ and ‘Bottom’ sides separately. And renamed all the yellow group outputs consistently (South, North, West, East, Bottom, Top).

Box Generator (60.1 KB)

Since all six sides have distinct origins, with some careful re-wiring my SrfDir cluster might not be needed at all? :thinking: Later - not so simple, I’ll leave it at that for now.