Text Entities are not supported in Rhino 8

Hi @clrkng @jonathon @AlanRynne
Text entities are not working in grasshopper in Rhino 8
Can you fix this? This is with latest connector 2.19.0-WIP
Could you look into this?


textEntititesNotWorkingRhino8.gh (17.3 KB)

2 Likes

Hey @Jonathan_Rabagliati ,

I can reproduce this. I just checked the code, in Rhino 7, text entities were referenced as Rhino text elements and converted accordingly. Looks like with Rhino 8, they added native support for Text Elements in Grasshopper. So this is not necessarily a regression.

We’ve added this to our backlog and tackle this together with support for newly added Grasshopper object types introduced in Rhino 8. In the meantime, you can still use Elefront to reference to text objects and send from there.

@gokermu Thanks for digging into this. Yes, it’d be great for Speckle to support many of the newly added Grasshopper Object types introduced in Rhino 8. TextEntity would be a good example to start with. SubD (introduced in Rhino 7) would also be great to add.

2 Likes

Incorporating support for native SubD can be quite complex. Currently, we have limited our SubD support to converting it into a Brep and sending it that way, which is the closest we can get to native in Rhino.

A post was split to a new topic: SubD Support in Rhino

@gokermu what the status on this? The Text Entities still doesn’t seem to work in Grasshopper with the 2.21.5 connector.

Hey @MortenLund,

Right now, we are focused on building next-gen connectors, so adding support for text entities has been deprioritized for the time being.

@gokermu okay that’s understandable. The Elefront-hack works for now.
Is there an easy way in C# to convert from Rhino.Geometry.TextEnterty to Objects.Other.Text?
I’m not familiar with the Speckle SDK (but proficient in Rhinocommon) and ChatGPT is being useless.

Check our rhino text conversion as a reference! speckle-sharp/Objects/Converters/ConverterRhinoGh/ConverterRhinoGhShared/ConverterRhinoGh.Other.cs at 89f2188625e4f6614131329d83b29740a8b3bc8c · specklesystems/speckle-sharp · GitHub

@clrkng thanks for the reference. I should just be able to call the Objects.Converter.RhinoGh.ConverterRhinoGh.TextToSpeckle method right?
For some reason i cant get a hold of the method…

this might help you… use Fennect plug-in and then use the Dev component “To Speckle” and send.

1 Like

Hmm strange. You should be able to reference it like so (are you missing an " at the end?):

But sometimes from my experience, gh code components can be buggy with references, especially with multiple.

If your env isn’t happy, you can always copypasta the conversion code explicity:

    var _text = new Text();
    _text.plane = PlaneToSpeckle(text.Plane);
    _text.rotation = text.TextRotationRadians;
    _text.height = text.TextHeight * text.DimensionScale; // this needs to be multiplied by model space scale for true height
    _text.value = text.PlainText;
    _text.richText = text.RichText;
    _text.units = ModelUnits; // get the doc units here

    return _text;

public Plane PlaneToSpeckle(RH.Plane plane, string units = null)
  {
    var u = units ?? ModelUnits; // get the doc units here
    return new Plane(
      PointToSpeckle(plane.Origin, u),
      VectorToSpeckle(plane.Normal, u),
      VectorToSpeckle(plane.XAxis, u),
      VectorToSpeckle(plane.YAxis, u),
      u
    );
  }
// and so on with point and vector to speckle
1 Like

Oh my god you’re right… I was missing a " … :flushed:

Couldn’t get the Converter to work, not sure why but got it working by explicitly converting it. Sharing it here if anyone else needs it.
Also @Nikos the Fennec solution didn’t work for me with the latest version from the Package Manager.

Thanks for the help!! :love_you_gesture:

// Grasshopper Script Instance
#region Usings
using System;

#r "%AppData%\Speckle\Kits\Objects\Objects.dll"
using Objects.Other;

using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
#endregion

public class Script_Instance : GH_ScriptInstance
{
    private void RunScript(TextEntity TxtEentity, ref object SO)
    {
        //var tjeck = new Objects.
        Rhino.Geometry.TextEntity text = TxtEentity;

        var _text = new Objects.Other.Text();
        _text.plane = PlaneToSpeckle(text.Plane);
        _text.rotation = text.TextRotationRadians;
        _text.height = text.TextHeight * text.DimensionScale; // this needs to be multiplied by model space scale for true height
        _text.value = text.PlainText;
        _text.richText = text.RichText;
        _text.units = RhinoDocument.ModelUnitSystem.ToString(); // get the doc units here

        SO = _text;
    }

    public Objects.Geometry.Plane PlaneToSpeckle(Rhino.Geometry.Plane plane, string units = null)
    {
        var u = units ?? RhinoDocument.ModelUnitSystem.ToString(); // get the doc units here

        Objects.Geometry.Point ori = new Objects.Geometry.Point(plane.OriginX,plane.OriginY,plane.OriginZ,u);
        Objects.Geometry.Vector vX = new Objects.Geometry.Vector(plane.XAxis.X,plane.XAxis.Y,plane.XAxis.Z,u);
        Objects.Geometry.Vector vY = new Objects.Geometry.Vector(plane.YAxis.X,plane.YAxis.Y,plane.YAxis.Z,u);
        Objects.Geometry.Vector vN = new Objects.Geometry.Vector(plane.Normal.X,plane.Normal.Y,plane.Normal.Z,u);

        Objects.Geometry.Plane pln = new Objects.Geometry.Plane(ori, vN, vX, vY, u);
        
        return pln;
    }
}

2 Likes