Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
replace text and mtext
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: replace text and mtext (Read 2495 times)
0 Members and 1 Guest are viewing this topic.
PM
Guest
replace text and mtext
«
on:
October 09, 2020, 11:01:32 AM »
Hi. I am using this lisp code to replace text and mtext. The problem is when i have a multy line mtext change only the first line and not all the mtext. Can any one help ?
Thanks
Code - Auto/Visual Lisp:
[Select]
;;; By Muhammad Zubair Ahmad
;;; 26 March 2002
;;;
;;; REVISIONS
;;; 27 March 2002-- Minor bug fixes.
;;;
;;;--------------------------------------------------------------------------;
;;; DESCRIPTION
;;; This programme changes the text objects with selected text.
;;; The command is called with RT from the command line at which
;;; time the user is asked to select a text object whose tex is to be
;;; used as sampled:
;;;
;;; Select a Text Object:
;;;
;;; If a non-text object is selected the message
;;;
;;; ERROR:"xxxxx" selected...., Please Try Again!
;;; Select a Text Object:
;;;
;;; is displayed
;;;
;;; Select Destination Objects:
;;; Select objects:
;;;
;;; Successfull completed.
;;;
;;;---------------------------------------------------------------------------;
;;;
;;; Main function -- no arguments
(
Defun
RepText
(
/
nonText test Org Runn e e1 e2 t1 t2 txt sset lenth1
)
(
setq
nonText
nil
)
(
While
(
not
nonText
)
(
setq
e
(
car
(
entsel
"
\n
select text or Mtext: "
)
)
)
(
Setq
e1
(
entget
e
)
)
(
setq
t1
(
assoc
1
e1
)
)
(
setq
txt
(
cdr
(
assoc
0
e1
)
)
)
(
setq
nonText
(
or
(
equal
txt
"MTEXT"
)
(
equal
txt
"TEXT"
)
)
)
(
princ
"
\n
_____"
)
(
if
(
not
nonText
)
(
princ
(
strcat
"
\n
ERROR:
\"
"
txt
"
\"
selected...., Please Try Again!"
)
)
)
)
(
princ
"
\n
.."
)
(
Princ
"
\n
Select Destination Objects:"
)
(
setq
sset
(
ssget
)
)
(
setq
test
0
Org
0
Runn
0
)
(
if
sset
(
progn
; then execute
(
setq
lenth
(
sslength
sset
)
)
(
while
(
<
test lenth
)
(
Setq
e2
(
entget
(
ssname
sset test
)
)
)
(
setq
txt
(
cdr
(
assoc
0
e2
)
)
)
(
if
(
or
(
=
txt
"TEXT"
)
(
=
txt
"MTEXT"
)
)
(
progn
; then execute
(
setq
t2
(
assoc
1
e2
)
)
(
setq
e2
(
subst
t1 t2 e2
)
)
(
entmod
e2
)
(
if
(
equal
e2 e1
)
(
setq
Org
1
)
(
Setq
Runn
1
)
)
)
; end progn
)
; end if
(
setq
test
(
+
test
1
)
)
)
; end while
(
if
(
and
(
=
Org
0
)
(
=
Runn
1
)
)
(
command
"erase"
e
""
)
)
(
princ
"
\n
Successfully completed. "
)
(
princ
)
)
; end progn
(
progn
; else show message
(
princ
"
\n
Nothing selected - command terminated"
)
(
princ
)
)
; end progn
)
; end if
)
; end function
;;; The C: function definition.
(
defun
c:RET
(
)
(
RepText
)
)
(
princ
"
\n
\t
RepText.lsp loaded. Start command with RET. (Prep'd by: Engr. Zubair)"
)
(
princ
)
Logged
ronjonp
Needs a day job
Posts: 7529
Re: replace text and mtext
«
Reply #1 on:
October 09, 2020, 11:05:09 AM »
Use vla-get-textstring .. long mtext strings store the text in multiple 3 dxf codes.
Code - Auto/Visual Lisp:
[Select]
(
3
.
"{
\\
fArial|b0|i0|c0|p34;sadfdsfdsfdsfsdfdsfds
\\
P
\\
P
\\
pxi-3,l4,t4;1)
\t
ssssssss sdsdsd dssdsds sds dsd sd s sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsdsd sd s d
\\
P2)
\t
ssssssss sdsdsd dssdsds sds dsd sd s sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsds"
)
(
3
.
"d sd s d
\\
P3)
\t
ssssssss sdsdsd dssdsds sds dsd sd s sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsdsd sd s d
\\
P4)
\t
ssssssss sdsdsd dssdsds sds dsd sd s sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsdsd sd s d
\\
P5)
\t
ssssssss sdsdsd dssdsds sds dsd sd s "
)
(
3
.
"sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsdsd sd s d
\\
P6)
\t
ssssssss sdsdsd dssdsds sds dsd sd s sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsdsd sd s d
\\
P7)
\t
ssssssss sdsdsd dssdsds sds dsd sd s sd ds ds dsd d dsdsdsdsdsdsd sds sd sd sd sd sdsds"
)
(
1
.
"d sd s d
\\
P
\\
pi0,l0,tz;
\\
Pasassssssssssssssssssssssasas asas as as a sa sas as a sa as sas asasasasassas asa}"
)
Logged
Windows 11 x64 - AutoCAD /C3D 2023
Custom Build PC
PM
Guest
Re: replace text and mtext
«
Reply #2 on:
October 09, 2020, 11:33:29 AM »
hi ronjonp. Can you fix it ?
Thanks
Logged
ronjonp
Needs a day job
Posts: 7529
Re: replace text and mtext
«
Reply #3 on:
October 09, 2020, 02:30:00 PM »
Quote from: PM on October 09, 2020, 11:33:29 AM
hi ronjonp. Can you fix it ?
Thanks
Why don't you take a stab at it first ?
Logged
Windows 11 x64 - AutoCAD /C3D 2023
Custom Build PC
jtoverka
Newt
Posts: 127
Re: replace text and mtext
«
Reply #4 on:
October 09, 2020, 02:38:36 PM »
Lee mac has a program called 'Batch Find & Replace Text'
http://www.lee-mac.com/bfind.html
If that doesn't satisfy your requirements, it at least has the code that can.
Logged
PM
Guest
Re: replace text and mtext
«
Reply #5 on:
October 10, 2020, 03:19:59 AM »
Hi jtoverka. I ask if someone can update the code because some times i have a big mtext and i need to replace it with another .
Thanks
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
replace text and mtext