Jump to content

(Custom request) Quick Unformat - LeeMac


haisagiviz

Recommended Posts

Hi everyone,

I am using Quick unformat Mtext lisp from Lee Mac, it is great lisp but I want to keep Paragraph format for Mtext.
Anyone can help me to fix it in this lisp.

 

;;------------------------------------------------------------;;
;;--- REMOVE FORMAT MTEXT ---
;;------------------------------------------------------------;;

;; Quick Unformat  -  Lee Mac
;; Returns a string with all MText formatting codes removed.
;; rgx - [vla] Regular Expressions (RegExp) Object
;; str - [str] String to process

(defun LM:quickunformat ( rgx str )
    (if
        (null
            (vl-catch-all-error-p
                (setq str
                    (vl-catch-all-apply
                       '(lambda nil
                            (vlax-put-property rgx 'global     actrue)
                            (vlax-put-property rgx 'multiline  actrue)
                            (vlax-put-property rgx 'ignorecase acfalse) 
                            (foreach pair
                               '(
                                    ("\032"     . "\\\\\\\\")
                                    (" "        . "\\\\P|\\n|\\t")
                                    ("$1"       . "\\\\(\\\\[ACcFfHKkLlOopQTW])|\\\\[ACcFfHKkLlOopQTW][^\\\\;]*;|\\\\[ACcFfKkHLlOopQTW]")
                                    ("$1$2/$3"  . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);")
                                    ("$1$2"     . "\\\\(\\\\S)|[\\\\](})|}")
                                    ("$1"       . "[\\\\]({)|{")
                                    ("\\$1$2$3" . "(\\\\[ACcFfHKkLlOoPpQSTW])|({)|(})")
                                    ("\\\\"     . "\032")
                                )
                                (vlax-put-property rgx 'pattern (cdr pair))
                                (setq str (vlax-invoke rgx 'replace str (car pair)))
                            )
                        )
                    )
                )
            )
        )
        str
    )
)

 

Thank you so much.

HAI

Link to comment
Share on other sites

Can you share with all of us what exactly you want?  What exactly this .lsp does that you don't want, and what result you do want... ?

  • Like 1
Link to comment
Share on other sites

Change:

("$1"       . "\\\\(\\\\[ACcFfHKkLlOopQTW])|\\\\[ACcFfHKkLlOopQTW][^\\\\;]*;|\\\\[ACcFfKkHLlOopQTW]")

to:

("$1"       . "\\\\(\\\\[ACcFfHKkLlOopQTW])|\\\\[ACcFfHKkLlOoQTW][^\\\\;]*;|\\\\[ACcFfKkHLlOoQTW]")

And:

("\\$1$2$3" . "(\\\\[ACcFfHKkLlOoPpQSTW])|({)|(})")

to:

("\\$1$2$3" . "(\\\\[ACcFfHKkLlOoPQSTW])|({)|(})")

 

  • Thanks 1
Link to comment
Share on other sites

On 10/2/2019 at 12:55 AM, Lee Mac said:

Change:


("$1"       . "\\\\(\\\\[ACcFfHKkLlOopQTW])|\\\\[ACcFfHKkLlOopQTW][^\\\\;]*;|\\\\[ACcFfKkHLlOopQTW]")

to:


("$1"       . "\\\\(\\\\[ACcFfHKkLlOopQTW])|\\\\[ACcFfHKkLlOoQTW][^\\\\;]*;|\\\\[ACcFfKkHLlOoQTW]")

And:


("\\$1$2$3" . "(\\\\[ACcFfHKkLlOoPpQSTW])|({)|(})")

to:


("\\$1$2$3" . "(\\\\[ACcFfHKkLlOoPQSTW])|({)|(})")

 

 

Thank @Lee Mac I fixed it but it was not working.
Sorry but could you please confirm the code again.

Link to comment
Share on other sites

On 10/1/2019 at 10:06 PM, Emmanuel Delay said:

Can you share with all of us what exactly you want?  What exactly this .lsp does that you don't want, and what result you do want... ?

I have the exported DWG from other CAD tool like Revit.

And I want to use the LISP to fix some problem of exported files automatically. And Mtext is overrided is one of the problems. I want to remove all of overrided of Mtext but keep only Paragraph. Mr. Lee Mac is knew this issue.

 

Thank all of you.

Link to comment
Share on other sites

On 10/3/2019 at 8:53 AM, haisagiviz said:

 

Thank @Lee Mac I fixed it but it was not working.
Sorry but could you please confirm the code again.

 

Could you post the exact MText content that you are supplying to the function?

 

11 hours ago, BIGAL said:

Hi Lee the version posted is different to what is now on your web site so trying to work out the rgx value.

 

This Quick Unformat function isn't (yet) published on my site, but only on various forums (e.g.); the rgx argument should be supplied with an instance of the Regular Expressions object, which may be created using:

(vlax-create-object "vbscript.regexp")

Note that this object should also be released.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...