Author Topic: ObjectDBX list  (Read 3191 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2084
ObjectDBX list
« on: June 18, 2014, 03:00:16 PM »

This is from Alan's  Replace Text routine using ObjectDBX. See comments in red below.

(defun c:replacetext (/ oldtx newtx)
  ;;  text to replace ("PARTY WALL" "COMMON WALL")
  (setq oldtx (strcase (getstring t "* Enter text to be replaced:")))
  (setq newtx (strcase (getstring T "* Enter new text:")))
  (TextReplaceDBX 3 ; both Model & Paper Space
    '(("OldText" "NewString")
      ;;("PARTY WALL" "COMMON WALL")  ;;this works
      (list oldtx newtx)  ;;this does not work
    )
  )
  (princ)
)


Thanks
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

reltro

  • Guest
Re: ObjectDBX list
« Reply #1 on: June 18, 2014, 03:52:45 PM »
Whats the question?

Try:
Code: [Select]
(defun c:replacetext (/ oldtx newtx)
  ;;  text to replace ("PARTY WALL" "COMMON WALL")
  (setq oldtx (strcase (getstring t "* Enter text to be replaced:")))
  (setq newtx (strcase (getstring T "* Enter new text:")))
  (TextReplaceDBX 3 ; both Model & Paper Space
    (list
        '("OldText" "NewString")
        (list oldtx newtx)
    )
  )
  (princ)
)


reltro

GDF

  • Water Moccasin
  • Posts: 2084
Re: ObjectDBX list
« Reply #2 on: June 18, 2014, 04:09:30 PM »
Thanks, but only this works. I just wanted to know why.

(TextReplaceDBX 3 ; both Model & Paper Space
    '(("OldText" "NewString")
      ("PARTY WALL" "COMMON WALL")
     )
  )
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

reltro

  • Guest
Re: ObjectDBX list
« Reply #3 on: June 18, 2014, 04:26:57 PM »
Thanks, but only this works. I just wanted to know why.

(TextReplaceDBX 3 ; both Model & Paper Space
    '(("OldText" "NewString")
      ("PARTY WALL" "COMMON WALL")
     )
  )

What is THIS?
I can't follow u, can't test anything...
ask a question so u are going to have an answer...

owenwengerd

  • Bull Frog
  • Posts: 452
Re: ObjectDBX list
« Reply #4 on: June 18, 2014, 04:31:37 PM »
When you use the quote function to form a quoted list as in '("the" "brown" "fox"), the list contents will not be evaluated. Therefore, your nested (list X Y) will not be evaluated. You can't quote the entire list in that case, as reltro already showed.

GDF

  • Water Moccasin
  • Posts: 2084
Re: ObjectDBX list
« Reply #5 on: June 18, 2014, 05:31:42 PM »
Here is where the original routine can be found:
http://www.theswamp.org/index.php?topic=14703.msg177823#msg177823

;;  TextReplace.lsp
;;  CAB 02/19/07 version 3

I just wanted to add this to Alan's routine and have it evaluated:
  (setq oldtx (strcase (getstring T "* Enter text to be replaced")))
  (setq newtx (strcase (getstring T "* Enter new text"))) 

(list '("OldText" "NewString") (list oldtx newtx) )
 
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2084
Re: ObjectDBX list
« Reply #6 on: June 18, 2014, 05:36:22 PM »
Thanks

It works now...I just can't get my head around lists.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ObjectDBX list
« Reply #7 on: June 18, 2014, 08:18:24 PM »
As Owen said this doesn't work
Quote
    '(("OldText" "NewString")
      (list oldtx newtx)
    )

because this quote ' stops any further evaluation so the imbedded list is ignored.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2084
Re: ObjectDBX list
« Reply #8 on: June 19, 2014, 10:05:45 AM »
As Owen said this doesn't work
Quote
    '(("OldText" "NewString")
      (list oldtx newtx)
    )

because this quote ' stops any further evaluation so the imbedded list is ignored.

Alan, all I know is the following works:  (list '("OldText" "NewString") (list oldtx newtx))
Your old routine works perfectly now and saves me a lot of time editing dtext in dozens of drawings.

(setq oldtx (strcase (getstring T "* Enter text to be replaced")))
  (setq newtx (strcase (getstring T "* Enter new text"))) 

  (TextReplaceDBX 3 ; both Model & Paper Space
        (list '("OldText" "NewString") (list oldtx newtx) )
  )
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2084
Re: ObjectDBX list
« Reply #9 on: June 20, 2014, 09:59:41 AM »
Here is Alan's TextReplace routine with my changes. I added Lee's LM:EditBox sub function, and Tony Tanzillo's Directory-Dia sub fuction.
Thanks to all that responded to my poorly worded question. Also thanks to Reltro and Owen for their help.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ObjectDBX list
« Reply #10 on: June 20, 2014, 10:48:23 AM »
I'm sure you tried Lee's routine too.
http://www.theswamp.org/index.php?topic=32777.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2084
Re: ObjectDBX list
« Reply #11 on: June 20, 2014, 10:59:45 AM »
Son of a Gun
No...I should have know Lee had one.
I'll search better next time.

Thanks
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64