C# TextEntity Plane Position is in a wrong location

Hi,

How can I retrieve actual textentity position?

My workflow:

  1. I get TextObject which is rhino object
  2. Then get TextGeometry from TextObject
  3. I add a base point of a plane to Rhino from TextEntity.Plane.Origin

And it is in a wrong position, as image below. Can there be any transformations, if yes how can I get the actual position?


Model.3dm (3.9 MB)

Hello @Petras_Vestartas

Your texts are in a block.
I suspect you need to apply your block transform to texts.

Thanks for an answer. How can I get instance transformation?
I do not find this property here
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_InstanceDefinition.htm

The transformation is inside the OpenNurbs object (not the Rhino object) Rhino.Geometry.InstanceReferenceGeometry

Does it mean I have to somehow cast instanceDefinition to this type?
Could you provide an example to get a transformation?

I started by using this sample

    Rhino.DocObjects.ObjRef objref;
    var rc = Rhino.Input.RhinoGet.GetOneObject("Select instance", false, Rhino.DocObjects.ObjectType.InstanceReference, out objref);
    if (rc != Rhino.Commands.Result.Success)
      return ...;

    var iref = objref.Object() as Rhino.DocObjects.InstanceObject;
    if (iref == null)
        return ...;

    var on_iref = iref.Geometry as Rhino.Geometry.InstanceReferenceGeometry;
    if (on_iref == null)
        return ...;

    Transform = on_iref.Xform;

Did you succeed?

It works for me:

    Rhino.DocObjects.ObjRef objref;
    var rc = Rhino.Input.RhinoGet.GetOneObject("Select instance", false, Rhino.DocObjects.ObjectType.InstanceReference, out objref);
    if (rc != Rhino.Commands.Result.Success)
      return rc;

    var iref = objref.Object() as Rhino.DocObjects.InstanceObject;
    if (iref == null)
        return Rhino.Commands.Result.Nothing;

    var on_iref = iref.Geometry as Rhino.Geometry.InstanceReferenceGeometry;
    if (on_iref == null)
        return Rhino.Commands.Result.Nothing;

    var transform = on_iref.Xform;

    var idef = iref.InstanceDefinition;
    if (idef != null)
    {
        var rhino_objects = idef.GetObjects();
        for (int i = 0; i < rhino_objects.Length; i++)
        {
            if (rhino_objects[i] is Rhino.DocObjects.TextObject textObject) {
                var point = textObject.TextGeometry.Plane.Origin;
                point.Transform (transform);
                RhinoDoc.ActiveDoc.Objects.AddPoint (point);
            }
        }
    }
        
    return Rhino.Commands.Result.Success;
1 Like

Thank you very much.
It works very well and position of TextEntity origin is in a correct location.