Anushka Posted March 30, 2021 Posted March 30, 2021 The program does not work as it does on the website. something wrong ? when I try to use the program and pass the correct parameters (same as the site) I don't have the same result as the site, is something wrong? (LM:UnFormat "{\\O\\C1;L\\C256;ee} {\\L\\C2;M\\C256;ac}" nil) "" Returns empty string (LM:UnFormat "\\A1;{\\T1.1;\\C1;a\\C256; \\H1.2x;\\C2;b\\H0.83333x;\\C256; \\C3;c} {\\H0.7x;\\C4;\\S1#2;}" nil) "" Returns empty string (LM:UnFormat "ADB10\\PADB10.1\\PADB10.2" nil) "ADB10 " A piece of string is missing ;;-------------------=={ UnFormat String }==------------------;; ;; ;; ;; Returns a string with all MText formatting codes removed. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; str - String to Process ;; ;; mtx - MText Flag (T if string is for use in MText) ;; ;;------------------------------------------------------------;; ;; Returns: String with formatting codes removed ;; ;;------------------------------------------------------------;; (defun LM:UnFormat ( str mtx / _replace rx ) (defun _replace ( new old str ) (vlax-put-property rx 'pattern old) (vlax-invoke rx 'replace str new) ) (if (setq rx (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq str (vl-catch-all-apply (function (lambda ( ) (vlax-put-property rx 'global actrue) (vlax-put-property rx 'multiline actrue) (vlax-put-property rx 'ignorecase acfalse) (foreach pair '( ("\032" . "\\\\\\\\") (" " . "\\\\P|\\n|\\t") ("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]") ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);") ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}") ("$1" . "[\\\\]({)|{") ) (setq str (_replace (car pair) (cdr pair) str)) ) (if mtx (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str)) (_replace "\\" "\032" str) ) ) ) ) ) (vlax-release-object rx) (if (null (vl-catch-all-error-p str)) str ) ) ) ) (vl-load-com) Quote
rkmcswain Posted March 30, 2021 Posted March 30, 2021 Have you tried contacting the author? http://www.lee-mac.com/contact.html 1 Quote
tombu Posted March 30, 2021 Posted March 30, 2021 (edited) (LM:UnFormat "{\\O\\C1;L\\C256;ee} {\\L\\C2;M\\C256;ac}" nil) returns "Lee Mac" exactly as it does in his example at http://www.lee-mac.com/unformatstring.html on my PC. Command: (LM:UnFormat "{\\O\\C1;L\\C256;ee} {\\L\\C2;M\\C256;ac}" nil) "Lee Mac" Command: (LM:UnFormat "ADB10\\PADB10.1\\PADB10.2" nil) "ADB10 ADB10.1 ADB10.2" Command: (LM:UnFormat "\\A1;{\\T1.1;\\C1;a\\C256; \\H1.2x;\\C2;b\\H0.83333x;\\C256; \\C3;c} {\\H0.7x;\\C4;\\S1#2;}" nil) "a b c 1/2" Edited March 30, 2021 by tombu added command line output Quote
ronjonp Posted March 30, 2021 Posted March 30, 2021 Same here with the examples above. Quote (LM:UnFormat "{\\O\\C1;L\\C256;ee} {\\L\\C2;M\\C256;ac}" nil) (LM:UnFormat "\\A1;{\\T1.1;\\C1;a\\C256; \\H1.2x;\\C2;b\\H0.83333x;\\C256; \\C3;c} {\\H0.7x;\\C4;\\S1#2;}" nil) (LM:UnFormat "ADB10\\PADB10.1\\PADB10.2" nil) "Lee Mac" "a b c 1/2" "ADB10 ADB10.1 ADB10.2" Quote
rlx Posted March 30, 2021 Posted March 30, 2021 same here... what autocad version are you working with? Looking at master Lee's code , he uses (vlax-get-or-create-object "VBScript.RegExp") and (if (null (vl-catch-all-error-p str)) str) Just thinking aloud , maybe VBScipt part isn't working , if so vl-catch-all-error kicks in? Quote
Lee Mac Posted March 30, 2021 Posted March 30, 2021 Thank you all for testing the function - I'm pleased to see that the function is performing as expected in the majority of cases. @Anushka If you are using the very latest version of AutoCAD in which the LISPSYS system variable is present, please try setting LISPSYS=0, as I've found that the introduction of Unicode compatibility to AutoLISP has impacted the evaluation of Regular Expressions such as used by my LM:Unformat function. Quote
Lee Mac Posted March 30, 2021 Posted March 30, 2021 44 minutes ago, rlx said: Looking at master Lee's code , he uses (vlax-get-or-create-object "VBScript.RegExp") and (if (null (vl-catch-all-error-p str)) str) Just thinking aloud , maybe VBScipt part isn't working , if so vl-catch-all-error kicks in? A good suggestion @rlx and thank you for testing the code, however if the vl-catch-all-apply expression were to return an error object, or if the LM:Unformat function cannot instantiate the Regular Expressions object, the function would return nil, rather than the mixed results reported by the OP. Quote
rlx Posted March 30, 2021 Posted March 30, 2021 @Lee , I was looking for something like (If err "" str) but couldn't find it but also didn't want to blame you so I blamed the next best thing , first time I hear that LISPSYS probably is to blame. Thanx for the intel Quote
Lee Mac Posted March 30, 2021 Posted March 30, 2021 10 minutes ago, rlx said: @Lee first time I hear that LISPSYS probably is to blame. Thanx for the intel You're welcome - here's where I first became aware of this issue: https://www.cadtutor.net/forum/topic/70432-lmunformat-and-variable-lispsys-in-autocad-2021/ Quote
tombu Posted March 31, 2021 Posted March 31, 2021 I've been using Civil 3D 2021 since the first update and use a lot of code from Lee and others. I've never had an issue. Anushka are you still using AutoCAD 2014? Have updates been installed? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.