Size of imported TextEntity object

I would like to import some objects from an external file into the active doc. I call File3dm.Read() to populate a File3dm object, then I iterate through the loaded objects and add them to the active document.
Everything works fine except for TextEntity objects: the size and alignment of the imported text is completely wrong!
I’ve tried to setup the same annotation styles in both documents (the active one and the external one) but i’ve got the same result…
What can I do to fix this?
Thanks a lot!

Hi @software_comas,

Can you provide a sample file that you are trying to read? Are you using Rhino 5 or 6?

– Dale

Hi @dale!
I’m using Rhino6 SR11.
You can find the file I’m trying to read attached to this message.
Thanks! :slight_smile:

_TestSTAMP.3dm (67.4 KB)

After a couple of test, I have to say that the problem is a bit different: the objects I load from the file I sent before are used in a couple of different ways.

  1. They are drawn on screen inside the DrawOverlay method of a DisplayConduit derived class. In this case, the text (drawn simply by calling Display.DrawText(TextEntity, Color)) isn’t rendered properly. (see image below)

When user finalizes my command, they are added to the document and this is the final result:

As you can see, text is rendered properly only if objects are added to the document… Hope this helps to understand… Thanks again! :slight_smile:

Update. @dale
Text is drawn correctly (in the DisplayConduit) if I Explode() the TextEntity and draw the resulting curves insted of the single TextEntity.

@software_comas - It looks like the problem is that there are overrides to the dimstyle for text height and alignment for your text.
The sdk function doesn’t account for that and I don’t see another one that does.
@stevebaer - do you know of a way to draw text with overrides properly in a conduit?

Thanks, @lowell! I think you mean that there’s a conflict between two text styles: the one inside the open document and the one inside the importing document. Is it right?
In this case, do you think there’s a way to manage this kind of conflicts properly?

I mean that the primary dimstyle has text height = 1, left, bottom alignment and the text in your file has overrides to height = 7 and alignment to middle center, and that those overrides aren’t drawn correctly by
Display.DrawText().

We use something similar to that to position text when the Text command runs. There is a conduit that calls DrawText(text, color, xform) that draws the text while it is being positioned and gets the overrides right.

Maybe something like this will help:

      RhinoViewport vport = View().ActiveViewport;
      scale = AnnotationBase.GetDimensionScale(doc, dimensionStyle, vport);
      text_xform = text.GetTextTransform(scale, dimensionStyle);
      DrawText(text, color, xform);

Beyond that, I’d have to watch something run.

That’s enough: it works like a charm!
Thanks a lot, @lowell! :slight_smile:

Well, @lowell, it works for DisplayConduit but the same code doesn’t work when adding TextEntity to document: it’s position isn’t correct… Any ideas?
Anyway, thanks again! :slight_smile:

I thought you said above that you had it working right in the model, but not in the conduit

Well… That’s exactly what i wrote. But after some more testing, I found that it doesn’t work with all the docs I’m working with…
Maybe some kind of dimstyles conflict?
What happens if I’m workign with 2 documents with the same dimstyle but with different dimstyle settings?

If you read a second file with a dimstyle that has a name conflict with a dimstyle in a primary file, you have to either use the settings in the primary file or manage the name conflict in some other way.
Dimstyle in a Rhino model must have unique names.

Thanks, @lowell!
Thtat’s exactly what i had to know.
Now the fun part… :wink: