How to convert text dot to predictable, usable curves?

Hi everyone,

I need to streamline my process. I’m starting with text dots. I need to convert them to a specific font for CNC engraving (the font can only be comprised of closed curves, which are necessary for the nesting software I use)…

I can manually generate the font using Rhino\s TextObject dialog (selecting “curves” as output). It works fine, except I have hundreds of text dots. I need to automate this.

The attached image shows what seems like a solution, except that the result isn’t quite right. The “e” characters are funky looking and some areas converge to a point. Apparently, the curves derived from exploded text are not the same as the curve output from the TextObject command. Am I overlooking something? Not all fonts create this problem, but I’d like to continue using the font in the example (Existence Stencil Light).

I’m not bound to this workflow either (grasshopper and/or scripts are welcome), so if you know another way to go from textdots to well behaved curves (as created with the TextObject command) please point me in the right direction. Many thanks!

cbass

Well, I think the best way would be to create the TextObject curves directly with a script, either extracting the text from the dots, or some other way… The main thing is that text dots are “screen space” objects that always face the camera, whereas TextObjects will need a CPlane to be created. That could be either the current active CPlane or something like Top depending on what you need…

One thing you could try on your “curves don’t look right” converted text is to try running ConvertToBeziers on them and see if that helps any…

–Mitch

There was (is?) a bug in the text explode code that messes up fonts that are ‘not closed’.
There is some more background here:
http://discourse.mcneel.com/t/exploding-text-is-broken/

I suppose you could try to use Inkscape to convert text to curves…

Thank you both for your replies.

Mitch, I have tried your suggestion but it doesn’t help. When comparing the bad output of the exploded text to the result from TextObject, I’ve just noticed that the bad version has fewer control points on its curves. They are essentially missing in key areas, so what should be a rectangle with 4 control points becomes a triangle with 3 control points (I can actually recreate the bad curves if I start with the good ones and start deleting CP’s). I guess I am imagining that there is a way to access the TextObject prompt through scripting, using the info from the dots as input, but that is a little beyond my skills!

Wim, thanks for the link. Having checked it out, I see both you and Mitch have encountered this in the past! Oh well, it looks like it hasn’t been resolved in Rhino. Maybe one day? I could use another program, but I really want to keep this native to Rhino.

If you or anyone else has any other suggestions, I’m all ears… Thanks!

cbass

I can try and hack something together to test… --Mitch

Here is a test script to try…

Current limitations -

  • Uses active view CPlane
  • Will not work with multi-line dots (not sure if I can fix)
  • TextObject is inserted above and to the right of dot center point. (this can be fixed later)
  • In the script, substitute your desired font name for “Arial” on line font_style="Arial"

Let me know if this is going in the right direction and what needs to be changed.

–Mitch

import rhinoscriptsyntax as rs

def CreateTextObjsAsCurves(text_string,pt,ht,font):
    #creates text object in form of curves
    opts='_GroupOutput=_Yes _FontName="{}" _Italic=_No _Bold=_No '.format(font)
    opts+='_Height={} _Output=_Curves _AllowOpenCurves=_No '.format(ht)
    opts+='_LowerCaseAsSmallCaps=_No _AddSpacing=_No '
    rs.Command("_-TextObject "+opts+'"'+text_string+'"'+" " + str(pt),False)
    if rs.LastCommandResult()==0: return rs.LastCreatedObjects()

def ConvertDotsToTextObject():
    font_style="Arial"
    dots=rs.GetObjects("Select text dots to convert",8192,preselect=True)
    if not dots: return
    txt_ht=rs.GetReal("Text object height",minimum=rs.UnitAbsoluteTolerance())
    if txt_ht==None: return
    txt_objs=[]
    rs.EnableRedraw(False)
    for dot in dots:
        text=rs.TextDotText(dot)
        pt=rs.TextDotPoint(dot)
        txt_obj=CreateTextObjsAsCurves(text,pt,txt_ht,font_style)
        if txt_obj: txt_objs.append(txt_obj)
        rs.DeleteObject(dot)
ConvertDotsToTextObject()
2 Likes

Thanks Mitch! That certainly worked. As an aside, the script originally wasn’t recognizing the particular font I was trying to use (“(Existence Stencil Light”), but it was working with other more common fonts. I ended up installing that same font on another computer with Rhino. In that case, I was able to simply explode the text and that resulting curves where fine. Also, your script worked on that computer as expected. So I went back to the original computer I noticed the problem on, uninstalled and reinstalled the font. That solved the issue. I guess the font I had was corrupt…

While reinstalling the font solved the issue of exploding regular text to curves, your script is useful to me for a couple of reasons.

1- It saves me having to convert the text dots before exploding and more importantly
2- the result of going through the TextObject command produces much cleaner geometry than simply exploding text. I’ve attached some images for comparison. Its pretty clear when you zoom in how rough the curves resulting from exploded text actually are!

Finally, I had trouble at first as I though it was a RhinoScript. I ended up running it as a python script (which I haven’t used before!).

I really appreciate you having helped.

Thanks!

cbass