Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
jmaeding
Posts: 969
Registered: ‎12-27-2006
Message 1 of 12 (264 Views)

Split text string to characters, including %%D and unicode items

264 Views, 11 Replies
04-24-2014 10:39 AM

I am making a tool to draw text along plines, and need to split my strings to charcaters.

I know to look for %%D, %%C and several others, but I am wondering if there is a way to detect the difference between the original string charcater count, and the one acad would draw with a given text style.

If the lengths were different, I could check for sequences and handle.

I want to avoid checking every time though, and also detect when some exotic sequence got in that I was not checking for.

 

lisp or .net....

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 12 (237 Views)

Re: Split text string to characters, including %%D and unicode items

04-24-2014 11:57 AM in reply to: jmaeding

Hi, James

I didn't find .net example here is just C# snip:

 //using System.Text.RegularExpressions;
            //string text = "200%%C";
             string text ="200%%D";      
            string pattern = @"(.*?)%%[D,C]";
            int dia = 0;
            MessageBox.Show(text.Contains("%%D").ToString());
           Regex.Matches(text, pattern).Cast<Match>().All((Match m) =>
           {
               dia = Convert.ToInt32(m.Groups[1].Value);
               return true;
           });
           MessageBox.Show(dia.ToString());

 

 

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
jmaeding
Posts: 969
Registered: ‎12-27-2006
Message 3 of 12 (234 Views)

Re: Split text string to characters, including %%D and unicode items

04-24-2014 12:05 PM in reply to: Hallex

That's slick code, and I will add to my c# library of string extensions.

It approaches things from a standpoint of knowing what to look for though.

 

What if I said "are there any sequences in some string that get converted to one character, or disappear altogether?"

Things like %%U and %%D.

The only way to test that would be some function that looked at the final text value and gave back ascii character values of final string.

%%D seems the same as (chr 176), but I wonder how dependednt this all is on the font.

What if autodesk changes the allowed sequences in strings?

We really need something that gets down to the final characters being displayed. For mtext too...

 

 

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 12 (226 Views)

Re: Split text string to characters, including %%D and unicode items

04-24-2014 12:40 PM in reply to: jmaeding
James, it's too difficult for my dim brain,
I will try to continue tomorrow, though, about fonts,
not every supports characters like in your example, as I remember it
See you later
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
jmaeding
Posts: 969
Registered: ‎12-27-2006
Message 5 of 12 (221 Views)

Re: Split text string to characters, including %%D and unicode items

04-24-2014 12:56 PM in reply to: Hallex

dim is as dim does, so GET CRACKING!!!!!

kidding, thx for the help so far :smileyhappy:

Distinguished Mentor
BlackBox_
Posts: 745
Registered: ‎02-25-2013
Message 6 of 12 (207 Views)

Re: Split text string to characters, including %%D and unicode items

04-24-2014 02:42 PM in reply to: jmaeding

FWIW -

 

Here are some additional String extension methods (C#) I came up with while working on this.

 

Cheers



"Potential has a shelf life." - Margaret Atwood


Autodesk Exchange Apps ~ Autoloader ~ AutoCAD Security

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 7 of 12 (186 Views)

Re: Split text string to characters, including %%D and unicode items

04-24-2014 11:29 PM in reply to: jmaeding
Can you upload text string example for the test?
For mtext too
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
jmaeding
Posts: 969
Registered: ‎12-27-2006
Message 8 of 12 (167 Views)

Re: Split text string to characters, including %%D and unicode items

04-25-2014 01:05 PM in reply to: Hallex

sure:

"try this /U+0178"

 

you see, I have no idea if /U+0178 is a special code that will show as one character, or a typo and it should be /U+0128 or something.

Sequences we think will transform to a character may or may not work in a given environment.

So if my task is to split a string into actual characters that will be drawn, I cannot assume anything.

 

I will check with Kean W on this, seems like this has come up a while back with .net.

Distinguished Mentor
BlackBox_
Posts: 745
Registered: ‎02-25-2013
Message 9 of 12 (160 Views)

Re: Split text string to characters, including %%D and unicode items

04-25-2014 01:30 PM in reply to: jmaeding

In terms of .NET API (I know this thread is still in LISP forum), the TextEditor.Selection.RemoveAllFormatting() Method may be of use here.



"Potential has a shelf life." - Margaret Atwood


Autodesk Exchange Apps ~ Autoloader ~ AutoCAD Security

Distinguished Contributor
jmaeding
Posts: 969
Registered: ‎12-27-2006
Message 10 of 12 (156 Views)

Re: Split text string to characters, including %%D and unicode items

04-25-2014 01:36 PM in reply to: BlackBox_

I think that was what I recalled, but does not pertain to the special character sequences unfortunately.

This might be a tougher question than I thought.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.