Explodable 3D Text - Similar to Fabtools 3D Text Advanced

SOLVED: For anyone looking into this thread in the future, this has been solved in Rhino 6 with a C# script (courtesy of qythium). See posts from 24th of April which contain a working definition.

Note warnings from obsolete code are still present but do not prevent operation.

ORIGINAL POST

Hi all,
Wondering if anyone has come across a 3D text tag that can be produced, then manipulated inside grasshopper? I know Grasshopper has a built in 3D text tag, but it has no output for further manipulation.

With Rhino 5 I have been using the FabTools “Text 3D Advanced” along with his “Text Contour” component, which exports curves that represent your text.

https://rhino.github.io/components/fabtools/text3DAdvanced.html

Unfortunately the 3D Text Advanced doesn’t work with Rhino 6 :frowning:

If anyone is aware of a similar grasshopper componant please let me know!

Cheers
Lyndon

2 Likes

@LyndonJ, same problem here, actually even worse, some of my text goes upside down when I explode the text inside rhino.

Our problem would be solved with a curve output, right?

@DavidRutten, what do I need to do not to have my numbers upside down? Command bar says Curves from text may orient differently than text in viewports because of Annotation style settings. There is an option inside Annotation style settings but for me, it doesn’t do anything. On the screenshot you can see text on overhanging surfaces of a climbing wall. I want the text aligned the way I define inside Grasshopper.

Plus can we please get a curve output on the 3D Text Tag?

Thanks for your help!

Yes, we can bake text and extrude it to solids. But isn’t the whole point of Grasshopper that we can actually automate everything? That much for the person who’s telling me I need to bake the text in order to select it, extrude in 20 different directions and subtract from another few solids to get my text engraved… :sob:

I don’t know yet what bugs got fixed in R6 but from nearly a week of experience with it (after four years with R5), I’m seeing bugs and unpleasant surprises at every turn!! :frowning:

I think this qualifies as a forward-compatibility bug in Rhino 6 - looking at the error messages in the FabTools 3D Text Advanced component, it’s trying to set the property
Rhino.Geometry.TextEntity.AnnotativeScalingEnabled which does not exist in RH6.
At the least the property should still be there and raise a “X is obsolete” compiler warning, even if it does nothing?

Here’s a simple C# script I wrote a while back that should work on all platforms - it returns the exploded text contours which you can manipulate like any regular curves:

text_contours_script.gh (8.5 KB)

    Component.Name = "Text Contours 3D";
    Component.Params.First(p => p.Name == "J").Description = @"
      0: Top Left
      1: Top Center
      2: Top Right
      3: Middle Left
      4: Middle Center
      5: Middle Right
      6: Bottom Left
      7: Bottom Center
      8: Bottom Right";
    Component.Params.First(p => p.Name == "style").Description = @"
      0: Regular
      1: Bold
      2: Italic
      3: Bold Italic";
    bool bold = style == 1  || style == 3;
    bool italic = style == 2 || style == 3;
    int tmb = 1 << (16 + 2 - J / 3);
    int lcr = 1 << (J % 3);

    TextEntity _text = new TextEntity();
    _text.Plane = Pl;
    _text.Text = (T == null) ? "" : T;
    _text.TextHeight = (S <= 0) ? 1 : S;
    _text.FontIndex = RhinoDoc.ActiveDoc.Fonts.FindOrCreate(font, bold, italic);
    _text.Justification = (TextJustification) (tmb | lcr);

    C = _text.Explode();
5 Likes

martinsiegrist Thanks for your reply, did you want to upload your model and GH script and I will take a look? I have never had issues with upside down text before, and have used it extensively. Wouldn’t solve the automation issue but qythium’s post might sort us out!.

qythium Thank you for uploading the script :slight_smile: I will have a go with that today and let you know how it goes.

@ qythium

Your script was exactly what I was looking for, thank you. I have not yet tried it on a large scale (The work I am doing involves several thousand characters, automated notes against a geotechnical model, a model of under-ground conditions from drilling etc).

I had a go with an arbitrary plane and few bits of text, and it functioned but I noted the justification was not working. It seems to suffer the same issues that the FabTools plugins suffered from. See below:

I can probably fix the FabTools bug in V6. Do you have a simple definition that shows the bug with “Text 3D Advanced”?

1 Like

See the attached, which works on RH5 but not on RH6.
text_contours_minimal.gh (111.6 KB)

FabTools components actually appear to be password-protected clusters and don’t need a gha plugin to be installed, I’ve included one in the file as well.

As noted by LindonJ above TextEntity.Justification is also broken - looks like it’s been replaced by the new properties TextHorizontalAlignment and TextVerticalAlignment but should really still function as a sort of obsoleted alias.

Here’s another screenshot:

will try the script later…

@FlorianFrank I’m just mentioning Florian Frank here and hope he sees this. It would be awesome if Fabtools could be updated to V6.

2 Likes

Of course this would be nice too!

In general, I think that by now most of us who work with Grasshopper on a daily basis recognize certain pros and cons. Tools within plugins such as fabtools or elefront are often really close to existing, native Grasshopper tools. The goal should be to improve these lacking native tools. Thanks :pray: @DavidRutten

2 Likes

@martinsiegrist I agree, if we could get some of these functions as native components that would be the best :slight_smile: - But in the mean time we will make do with what we can. I think qythium’s script is almost there - I made some minor edits to output both text, and contours (which i will re-upload here if we get it working) - but haven’t been able to correct the text justification as yet.

@ qythium Could you give me an example of how the TextHorizontalAlignment and TextVerticalAlignment can be used in your script? I tried replacing:

“_text.Justification = (TextJustification) (tmb | lcr);”

With

“_text.TextAlign = HorizontalAlignment.Center;”

But its throwing the following error:

  1. Error (CS1061): ‘Rhino.Geometry.TextEntity’ does not contain a definition for ‘TextAlign’ and no extension method ‘TextAlign’ accepting a first argument of type ‘Rhino.Geometry.TextEntity’ could be found (are you missing a using directive or an assembly reference?) (line 96)

I’m new to C# (usually fall back on VBA… since i dont do alot of programming). If you could advise how to edit the “_text.Justification” line to function in Rhino 6 that would be most appreciated.

I can’t test it out on a Rhino 6 for the next few days, but going by the documentation page, it should be something like

_text.TextHorizontalAlignment = (TextHorizontalAlignment) (J%3);

Vertical alignment is a little trickier since it looks like they’ve introduced a bunch more options besides Top, Middle and Bottom:

http://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_TextVerticalAlignment.htm

and the list is curiously incomplete - no MiddleOfBoundingBox, TopOfBottom, etc? I wouldn’t be surprised if the enum->int mappings get shuffled around in a future update, best to go with

switch (J/3) {
    case 0:
        _text.TextVerticalAlignment = TextVerticalAlignment.Top;
        break;
    case 1:
        _text.TextVerticalAlignment = TextVerticalAlignment.Middle;
        break;
    default:
        _text.TextVerticalAlignment = TextVerticalAlignment.Bottom;
        break;
}
1 Like

Thanks qythium

The code amendments corrected the justification. I had a go at adding a Rhino text-object output as well - as I prefer to bake text when working inside Rhino - and usually only bake the curves before I export to 3D PDF.

Edited code is copied below, see the line in bold - This doesn’t seem to result in text that can be previewed on-screen (or baked).

Is there any way to make the text entity also visible in the Rhino viewport?

Component.Name = "Text Contours 3D";
Component.Params.First(p => p.Name == "J").Description = @"
  0: Top Left
  1: Top Center
  2: Top Right
  3: Middle Left
  4: Middle Center
  5: Middle Right
  6: Bottom Left
  7: Bottom Center
  8: Bottom Right";
Component.Params.First(p => p.Name == "style").Description = @"
  0: Regular
  1: Bold
  2: Italic
  3: Bold Italic";
bool bold = style == 1 || style == 3;
bool italic = style == 2 || style == 3;
int tmb = 1 << (16 + 2 - J / 3);
int lcr = 1 << (J % 3);

TextEntity _text = new TextEntity();
_text.Plane = Pl;
_text.Text = (T == null) ? "" : T;
_text.TextHeight = (S <= 0) ? 1 : S;
_text.FontIndex = RhinoDoc.ActiveDoc.Fonts.FindOrCreate(font, bold, italic);
_text.TextHorizontalAlignment = (TextHorizontalAlignment) (J % 3);

switch (J / 3) {
  case 0:
    _text.TextVerticalAlignment = TextVerticalAlignment.Top;
    break;
  case 1:
    _text.TextVerticalAlignment = TextVerticalAlignment.Middle;
    break;
  default:
    _text.TextVerticalAlignment = TextVerticalAlignment.Bottom;
    break;
}

TXT = _text;

CRV = _text.Explode();

1 Like

Is the FabTools component Advanced Bake also broken on Rhino 6?

text_contours_script.gh (124.5 KB)

1 Like

The advanced bake works OK, generating a set of warnings about obsolete code - but nothing that prevents operation :slight_smile:

See images below.

Thanks again for your efforts on my behalf. If you are ever in Australia - I owe you a beer!

martinsiegrist
In case you did not already solve your text baking upside down issue - I believe this is caused by the oriented plane you are feeding the text module.

Rhino 6 will automatically adjust text so its legible regardless of the angle from which you view. When baking as curves - it reverts to its ‘true form’.

I have just been through this with my own project, and have solved it using a combination of dot product, cross product and angles between a master vector and each plane.

Feel free to upload your script if you would like me to take a look.

Rhino 6 will automatically adjust… that might be great for standard plans and such but what I wish is that this auto function can be deactivated. The deactivation currently does not work for me. Please @DavidRutten make it work…

Actually this issue is also not about baking. Take a look at the 4° overhanging surface on the image in my post from 4 days ago. The text is grouped with the surface. I can rotate the whole group and once a text orientation goes beyond 12 o clock, the number flips. It remains legible. Since I’m creating modeling sheets, I need a bunch of surfaces connected to each other and I simply don’t want Rhino to decide any text orientation what so ever.

Of course the orientation issue is caused by the plane I’m feeding. The orientations are correct in my 3D model and correct in my unrolled Grasshopper model.

I’m aware of how a number should be legible on a plan but let me deactivate this. Thanks

Hello,

Thank you for your plugin, it is really nice! I just came across one problem and I hope you know how to fit it: all the text I engrave is mirrored. If I make a plain with text for the top view, the text is readable in bottom view…

It sounds like a simpel plain problem but I just can’t figure it out…

Thanks in advance!

Im using ‘Text By Curve’ from Peacock.
https://grasshopperdocs.com/components/peacock/textByCurve.html

Unfortunately

But it still works (in v6)…