Author Topic: Find & Replace Script - Quick Question  (Read 16981 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
Find & Replace Script - Quick Question
« on: January 26, 2007, 03:53:21 PM »
We have about 100 or so drawings that were given temporary drawing numbers like SK-1234-01 while we waited to have proper drawing numbers assigned to us.  We now have those proper drawing numbers and we have to update all of the drawings before they go back to the client.  In order to make sure we cover all of the references to other drawings in addition to what's in the title block, this is what I'm thinking...

Would it be too much to expect from a script to do the following (pseudo script code):

Open SK-1234-01
Do a global find and replace on the text, "SK-1234-01" to "IS-923-01-34" and "SK-1234-02" to "IS-923-01-35" and basically go through the whole list, replacing the sketch number with the proper number (about 100).
SaveAs IS-923-01-34

The bold portion is what I'm wondering about... Although it might take a little while to get through the whole list, would it be too taxing on the PC to do this?  I don't think so, but I thought I'd throw it out there for you folks to see what you think.


(I will also have to do the exact same Find and Replace but removing the hyphens)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Find & Replace Script - Quick Question
« Reply #1 on: January 26, 2007, 04:01:43 PM »
CHText.lsp might do what you want
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Find & Replace Script - Quick Question
« Reply #2 on: January 26, 2007, 04:03:28 PM »
you can also make a rename.bat file to rename all your SK dwgs to IS dwgs.  You can make this halfway in about 3 minutes.  If you know what the numbers are going to be, and they are sequential, you might get the whole batch file in under 5 minutes
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #3 on: January 26, 2007, 04:05:19 PM »
CHText.lsp might do what you want

Yeppers!  :)

That's what I planned on using IN my script.

I may not have explained my issue very well.

I have a list of 100 drawings.  I have to open each drawing and replace 100 strings of text with 100 OTHER strings of text.

Now that I think of it, it sounds pretty simple... should do just fine.  I guess I might start to worry if it were 10 times that amount.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #4 on: January 27, 2007, 11:59:21 AM »
I have a lisp from Will Deloach that does that for all files in a directory using ObjectDBX. (Very Fast)
It would have to be modified to accommodate all the text you want to change as it was set up
to change only one text string. I tried to find the old code in the swamp but have had no luck
linking you to it.
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.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #5 on: January 27, 2007, 12:50:35 PM »
That sounds good Alan!

Well, on Monday, I'll be spending an hour or so looking into this to decide whether it's worth automating it or whether we should just do it manually.  We'll catch up with this one then.

Thanks!  :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #6 on: January 29, 2007, 08:24:04 AM »
Try this out Mike.
It only works in Modelspace in this first test version & only works with mText & plain Text.
I or someone else can add the layouts & attributes if you need them.
I am short of time this morning.
Code: [Select]
;;  TextReplace.lsp
;;  CAB 02/19/07 version 3

;;  Warning: There is no Undo, so back up your work.

;;  ObjectDBX Routine to replace text strings in all drawings in a
;;  selected folder

;;  This is a "Work In Progress"
;;  This is a collection of subroutines from several contributers
;;  at the Swamp & my own brand of tweaking. :) CAB

(defun TextReplaceDBX
       (flag textlist / DIRPATH DWGOBJ FULLPATH OBJ ODBX OLDTXT TEXTLIST TXT TXTLST)
  ;;  Add flag values
  ;;  flag 1 = ModelSpace Only
  ;;       2 = PaperSpace Only
  ;;       4 = Reserved
  ;;       8 = Include Attributed Blocks  * Not Operational
  ;;
  ;;  textlist = text to replace ("OldString" "NewString")

  (vl-load-com)
  (setq *acad (vlax-get-acad-object))


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                           
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun *error* (msg)
    (if
      (not
        (member
          msg
          '("console break" "Function cancelled" "quit / exit abort" "")
        )
      )
       (princ (strcat "\nError: " msg))
    )
    (if (and odbx (not (vlax-object-released-p odbx)))
      (vlax-release-object odbx)
    )
    (gc)
    (princ)
  )
  ;;end error function

  (defun get_atts (obj / val)
    (if (vl-catch-all-error-p
          (vl-catch-all-apply
            '(lambda ()
               (setq val (vlax-safearray->list
                           (vlax-variant-value (vla-getattributes obj))
                         )
               )
             )
          )
        )
      nil
      val
    )
  )


  (defun ReplaceText (phraselst document / txt oName swaptext ck_for_text)
    (defun swaptext (obj txtlst)
      (setq txt    (vla-get-textstring obj)
            Oldtxt txt
      )
      (mapcar '(lambda (x / tmp)
                 (if (setq tmp (vl-string-subst (cadr x) (car x) txt))
                   (setq txt tmp)
                 )
               )
              phraselst
      )
      (if (/= OldTxt Txt)
        (vla-put-textstring obj txt)
      )
    )

    (defun ck_for_text (obj oType lst)
          (cond ((vl-position oType '("AcDbText" "AcDbMText"))
             (swaptext obj lst)
            )
               
             ;|((and (> (logand flag 8) 0)
                  (eq oType "AcDbBlockReference")
                  (eq (vla-get-hasattributes item) :vlax-true)
             )
             (foreach for-item (get_atts item)
               (swaptext obj lst)
             )
            )|;
      )
    )

    (if (> (logand flag 1) 0)
    ;;  Model Space Only
    (vlax-for item (vla-get-modelspace document)
      (setq oName (vla-get-objectname item))
      (ck_for_text item oName textlist)
    )
    )
    (if (> (logand flag 2) 0)
    ;;  Paper Space Only
    (vlax-for item (vla-get-paperspace document)
      (setq oName (vla-get-objectname item))
      (ck_for_text item oName textlist)
    )
  )
  )



  ;;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  ;;        S T A R T   O F   M A I N   R O U T I N E       
  ;;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  (if (setq DirPath (getfiled "Browse for folder"
                              "Open a folder and click on SAVE"
                              " "
                              1
                    )
      )
    (setq DirPath (substr DirPath 1 (- (strlen DirPath) 31)))
  )

  (if DirPath
    (progn

     (setq odbx (if (< (setq Vers (substr (getvar "acadver") 1 2)) "16")
                       (vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument")
                       (vla-GetInterfaceObject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." Vers))
                     ))     
      (foreach Dwg (vl-directory-files DirPath "*.dwg" 1)
        (setq FullPath (strcat DirPath Dwg))
        (if (vl-catch-all-error-p
                  (vl-catch-all-apply
                                 '(lambda ()
                                    (vlax-invoke-method odbx 'open FullPath)
                                  )
                  )
            )
          (prompt (strcat "\n ++ Couldn't open drawing \"" FullPath "\""))
          (progn
            (prompt (strcat "\n  - Report for - " FullPath))
            ;;  Replace Strings
            (ReplaceText TextList odbx)

            (vla-saveas odbx (vla-get-name odbx))
          )
        )
      )
      (prompt "\n***  REGEN all drawings to display new text properly.  ***")
      (vlax-release-object odbx)
      (setq odbx nil)
    )
  )



  (princ)
)    ;  **  END MAIN PROCEDURE  **
(prompt "\nText Replace Loaded, enter TextReplace to run.")
(princ)


(defun c:TextReplace ()
  ;;  Add flag values
  ;;  flag 1 = ModelSpace Only
  ;;       2 = PaperSpace Only
  ;;       4 = reserved
  ;;       8 = Include Attributed Blocks  * Not Operational
  ;;
  ;;  text to replace ("OldString" "NewString")
  (TextReplaceDBX 3 ; both Model & Paper Space
    '(("OldText" "NewString")
      ("Test 012807.1" "NewString")
     )
  )
  (princ)
)
« Last Edit: February 19, 2007, 03:32:26 PM by CAB »
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.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #7 on: January 29, 2007, 08:30:49 AM »
Awesome!  Thanks, CAB!  I will be on that job in about 2 hours or so.  I'll let you know how it works out for me.

BTW, 98% of all of our work is done in modelspace and this particular client doesn't use attributes too often, but I can't thank you enough for doing that!!!  :-D

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Find & Replace Script - Quick Question
« Reply #8 on: January 29, 2007, 11:37:34 AM »
You might want to test this on one drawing first.  I don't know how well text is handled with ObjectDBX if the text is not left justified.  I know attributes will show up funny, but not sure about text.  Just an FYI...
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #9 on: January 29, 2007, 02:49:26 PM »
Tim,I have not tested it but Jeff Said:
Quote
Tim, the alignment problem is only with Attributes and only when you change the alignment. Just changing the value does not cause a problem, IIRC. I'm pretty sure that Autocad already prevents you from creating the Xrefs in a loop. Although a problem is encountered with nested Xrefs, which is why the Reload is wrapped by the (vl-catch-all-apply).....you can't reload a nested xref, only the parent xref.
http://www.theswamp.org/index.php?topic=8246.msg105654#msg105654
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Find & Replace Script - Quick Question
« Reply #10 on: January 29, 2007, 03:29:51 PM »
Tim,I have not tested it but Jeff Said:
Quote
Tim, the alignment problem is only with Attributes and only when you change the alignment <snip>
This statement is wrong, if you change the value of the attribute when it is justified to something besides left, then the display is messed up.  I think if you go in and edit it, then it will show correct.  I have tested this and know it to be true.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #11 on: January 29, 2007, 03:34:02 PM »
Thanks for the clarification, good to know.
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Find & Replace Script - Quick Question
« Reply #12 on: January 29, 2007, 03:36:30 PM »
I just tried it with just text, and when first opened it shows them in the wrong stop, but then with my company setup (it does somethings that I wish it wouldn't) it regened the drawing, and all the text is shown in the right spot.

FYI..

Thanks for the clarification, good to know.
You're welcome.
« Last Edit: January 29, 2007, 03:37:57 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #13 on: January 29, 2007, 03:43:20 PM »
Ha, you beat me to it. I was typing this. :-)
Did a quick test on plain text center justified. The text appeared off a bit but the grips were in the correct position.
If you regen then the text reappears in the correct location. The grips were in the correct location.
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Find & Replace Script - Quick Question
« Reply #14 on: January 29, 2007, 03:49:22 PM »
Ha, you beat me to it. I was typing this. :-)
i ninja!
Did a quick test on plain text center justified. The text appeared off a bit but the grips were in the correct position.
If you regen then the text reappears in the correct location. The grips were in the correct location.
This might be the same issue with attributes then, but to regen them you have to edit the block, or move it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #15 on: January 29, 2007, 05:41:49 PM »
Mike,
Did the routine work for you or blow you computer up.
I do hope it went OK. I revised the code to work with Paper Space and/or Model Space.

<code removed, see previous post>
« Last Edit: February 19, 2007, 03:33:32 PM by CAB »
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Find & Replace Script - Quick Question
« Reply #16 on: January 29, 2007, 05:59:18 PM »
Here is one I did for someone on the Adesk Ng.  You can use/ingnore/change it all you want.  Right now it only works in the current drawing, but that can easly be changed.  It will look through text, mtext, tables, blocks, dimensions, and attribute definitions.
Code: [Select]
(defun c:ReplaceAllStrings (/ ActDoc DtextList MtextList)

(defun ReplaceAllStrings (Doc MtextReplcList DtextReplcList / tempObjType ColCnt RowCnt)

(defun ReplaceString (String ReplaceList MtextObj / strTest strReplc Pos IsFormat FormatList strTemp)

(foreach pair ReplaceList
 (setq strTest (car pair))
 (setq strReplc (cdr pair))
 (setq Pos -1)
 (while
  (and
   (< Pos (strlen String))
   (setq Pos (vl-string-search strTest String (setq Pos (1+ Pos))))
  )
  (if (equal Pos 0)
   (setq String
    (strcat
     strReplc
     (if (<= (1+ (+ Pos (strlen strTest))) (strlen String))
      (substr String (1+ (+ Pos (strlen strTest))))
      ""
     )
    )
   )
   (setq String
    (strcat
     (substr String 1 Pos)
     strReplc
     (if (<= (1+ (+ Pos (strlen strTest))) (strlen String))
      (substr String (1+ (+ Pos (strlen strTest))))
      ""
     )
    )
   )
  )
  (setq Pos (+ Pos (strlen strReplc)))
 )
)
(if MtextObj
 (progn
  (setq Pos 1)
  (setq FormatList '("A" "Q" "T" "S" "H" "F" "C"))
  (setq IsFormat 0)
  (while (<= Pos (strlen String))
   (setq strTemp (substr String 1 1))
   (cond
    ((= strTemp "\\")
     (if (vl-position (substr String (1+ Pos) 1) FormatList)
      (setq IsFormat (1+ IsFormat))
     )
     (setq Pos (1+ Pos))
    )
    ((= strTemp ";")
     (if (equal IsFormat 0)
      (progn
       (if (equal Pos 1)
        (setq String
         (strcat
          "\\U+00B1"
          (if (<= 2 (strlen String))
           (substr String 2)
           ""
          )
         )
        )
        (setq String
         (strcat
          (substr String 1 (1- Pos))
          "\\U+00B1"
          (if (<= (1+ Pos) (strlen String))
           (substr String (1+ Pos))
           ""
          )
         )
        )
       )
       (setq Pos (+ Pos 7))
      )
      (progn
       (setq IsFormat (1- IsFormat))
       (setq Pos (1+ Pos))
      )
     )
    )
    (T (setq Pos (1+ Pos)))
   )
  )
 )
)
String
)
;---------------------------------------------------------------------------------------
(setq BlkCol (vla-get-Blocks Doc))
(vlax-for Lo (vla-get-Layouts Doc)
 (vlax-for Obj (vla-get-Block Lo)
  (setq tempObjType (vla-get-ObjectName Obj))
  (cond
   ((vl-position tempObjType '("AcDbText" "AcDbAttributeDefinition"))
    (vla-put-TextString Obj (ReplaceString (vla-get-TextString Obj) DtextReplcList nil))
   )
   ((= tempObjType "AcDbMText")
    (vla-put-TextString Obj (ReplaceString (vla-get-TextString Obj) MtextReplcList T))
   )
   ((wcmatch tempObjType "AcDb*Dimension")
    (vlax-for tempObj (vla-Item BlkCol (cdr (assoc 2 (entget (vlax-vla-object->ename Obj)))))
     (if (= (vla-get-ObjectName tempObj) "AcDbMText")
      (vla-put-TextString tempObj (ReplaceString (vla-get-TextString tempObj) MtextReplcList T))
     )
    )
   )
   ((= tempObjType "AcDbBlockReference")
    (foreach Att (vlax-invoke Obj 'GetAttributes)
     (vla-put-TextString Att (ReplaceString (vla-get-TextString Att) DtextReplcList nil))
    )
    (foreach Att (vlax-invoke Obj 'GetAttributes)
     (vla-put-TextString Att (ReplaceString (vla-get-TextString Att) DtextReplcList nil))
    )
   )
   ((= tempObjType "AcDbTable")
    (setq ColCnt 0)
    (repeat (vla-get-Columns Obj)
     (setq RowCnt 0)
     (repeat (vla-get-Rows Obj)
      (vla-SetText Obj (ReplaceString (vla-GetText Obj RowCnt ColCnt) DtextReplcList nil))
      (setq RowCnt (1+ RowCnt))
     )
     (setq ColCnt (1+ ColCnt))
    )
   )
  )
 )
)
)
;------------------------------------------------------------------------
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq DtextList
 (list
  (cons "^" "\\U+00B0")
  (cons ";" "\\U+00B1")
  (cons "_" "\\U+06F8") ;; Doesn't like new string
  (cons "|" "\\U+00BC")
  (cons "{" "\\U+215C")
  (cons "\\" "\\U+00BD")
  (cons "}" "\\U+215D")
  (cons "[" "\\U+00BE")
  (cons "]" "\\U+215E")
  (cons "~" "%%C")
  (cons "<" "\\U+2104") ;; Doesn't like new string
  (cons ">" "\\U+214A") ;; Doesn't like new string
 )
)
(setq MtextList
 (list
  (cons "^" "\\U+00B0")
  (cons "_" "\\U+06F8") ;; Doesn't like new string
  (cons "|" "\\U+00BC")
  (cons "\\{" "\\U+215C")
  (cons "\\\\" "\\U+00BD")
  (cons "\\}" "\\U+215D")
  (cons "[" "\\U+00BE")
  (cons "]" "\\U+215E")
  (cons "~" "%%C")
  (cons "<" "\\U+2104") ;; Doesn't like new string
  (cons ">" "\\U+214A") ;; Doesn't like new string
 )
)
(ReplaceAllStrings ActDoc MtextList DtextList)
(princ)
)

Edit:  Updated code.  I knew I had a better version, just coudn't find it before.
« Last Edit: January 30, 2007, 11:16:47 AM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #17 on: January 29, 2007, 06:58:08 PM »
Great Tim, thanks.
Waiting to see how Mike did before I go any further.
Work is pressing me. :-(
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.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #18 on: January 30, 2007, 01:42:41 PM »
I'm just getting into it now!   :x

Man, I hate it when work gets in the way of work... and other things.  :)

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #19 on: January 30, 2007, 01:49:36 PM »
I'm just getting into it now!   :x

Man, I hate it when work gets in the way of work... and other things.  :)

Scratch that... Work just got in the way again!!!

whdjr

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #20 on: January 31, 2007, 09:54:18 AM »
I have a lisp from Will Deloach that does that for all files in a directory using ObjectDBX. (Very Fast)
It would have to be modified to accommodate all the text you want to change as it was set up
to change only one text string. I tried to find the old code in the swamp but have had no luck
linking you to it.


I think this is the link you were talking about.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #21 on: January 31, 2007, 09:58:33 AM »
Yes, that's it. Thanks Will. :-)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #22 on: February 05, 2007, 11:30:00 AM »
Mike, did this ever happen? Or still pending?
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.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #23 on: February 05, 2007, 11:43:31 AM »
:oops: :cry:

Still pending.  I just have to wait until that boss comes in and tells me that his job takes precident over everyone else's work.  Just know that your work was not done in vain.  I WILL be getting to it.  It's just that these construction packages are more important to get out than that As Built package.

At the time I started this thread, I was in fact, on that job, but then things came up and well... I'm sure you've been in similar situations in the past...

:roll:

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #24 on: February 19, 2007, 11:31:11 AM »
Ok, I am FINALLY getting to this, but it's for a job other than the one that prompted this thread.  (if that made any sense... ? )

The error I get is "Error: Automation Error. Problem in loading application"

I run TEXTREPLACE, go select my (testing) folder and click on Save and that's what I get.  Suggestions?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #25 on: February 19, 2007, 12:18:55 PM »
Do you mean you run TextReplaceDBX
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.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #26 on: February 19, 2007, 12:26:43 PM »
:oops:

Nope.  I mean, I loaded and ran TextReplace.lsp and received that error.

(bear in mind that I'm a coding idiot)

What was my mistake?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #27 on: February 19, 2007, 12:29:53 PM »
Sorry for the confusion I created.
Enter this at the command line once it is loaded:
TextReplaceDBX
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.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #28 on: February 19, 2007, 12:33:30 PM »
Sorry for the confusion I created.
Enter this at the command line once it is loaded:
TextReplaceDBX
Once TextReplace.LSP is loaded, right?

(Just want to make sure)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Find & Replace Script - Quick Question
« Reply #29 on: February 19, 2007, 12:35:27 PM »
Sorry for the confusion I created.
Enter this at the command line once it is loaded:
TextReplaceDBX
Once TextReplace.LSP is loaded, right?

(Just want to make sure)
Yes.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #30 on: February 19, 2007, 12:41:51 PM »
I'm not getting it.

I must be missing something, which would also be par for the course.

Code: [Select]
Command: ad APPLOAD textreplace.LSP successfully loaded.


Command:
Text Replace Loaded, enter TextReplace to run.
Command:
Command: TextReplaceDBX
Unknown command "TEXTREPLACEDBX".  Press F1 for help.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #31 on: February 19, 2007, 12:49:30 PM »
How about TextReplace

Quote
Command:
Text Replace Loaded, enter TextReplace to run.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #32 on: February 19, 2007, 01:01:21 PM »
How about TextReplace

Quote
Command:
Text Replace Loaded, enter TextReplace to run.


That was the first one I tried and got

"Error: Automation Error. Problem in loading application"

I have to do a bunch of other stuff to these drawings as well, so I MAY end up just doing EVERYTHING with a script.  I would really hate for all of your help to be in vain, believe me!  I really hate the fact that A)  It's taken me this long to get to this issue, and B)  I can't contribute to the actual creation and troubleshooting of the code.  Just know that I truly do appreciate everyone's efforts just the same.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #33 on: February 19, 2007, 01:20:12 PM »
TextReplace is the correct command.

Which Acad version are you using ?

Try pasting this at the command line

(atoi (substr (getvar "acadver") 1 2))
« Last Edit: February 19, 2007, 01:24:09 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #34 on: February 19, 2007, 01:29:11 PM »
Which Acad version are you using ?
AutoCAD 2002

Try pasting this at the command line

(atoi (substr (getvar "acadver") 1 2))
15

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #35 on: February 19, 2007, 01:38:20 PM »
and this ?
Code: [Select]
      (setq *acad (vlax-get-acad-object))

      (setq odbx (if (< (atoi (substr (getvar "acadver") 1 2)) 16)
                   (vla-getinterfaceobject *acad "ObjectDBX.AxDbDocument")
                   (vla-getinterfaceobject *acad "ObjectDBX.AxDbDocument.16")
                 )
      )

« Last Edit: February 19, 2007, 01:49:13 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #36 on: February 19, 2007, 01:41:32 PM »
and this ?
Code: [Select]
      (setq odbx (if (< (atoi (substr (getvar "acadver") 1 2)) 16)
                   (vla-getinterfaceobject *acad "ObjectDBX.AxDbDocument")
                   (vla-getinterfaceobject *acad "ObjectDBX.AxDbDocument.16")
                 )
      )



Error: Automation Error. Problem in loading application

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #37 on: February 19, 2007, 01:42:55 PM »
OK .. in 2002 DBX isn't automatically registered.

Try this as a once off ..
Code: [Select]
(STARTAPP "regsvr32.exe"
          (STRCAT "/s \"" (FINDFILE "axdb15.dll") "\"")
)



added:
...
then try the previous again.
*** make sure to run this first
Code: [Select]
(setq *acad (vlax-get-acad-object))
« Last Edit: February 19, 2007, 01:48:25 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #38 on: February 19, 2007, 01:45:37 PM »
OK .. in 2002 DBX isn't automatically registered.

Try this as a once off ..
Code: [Select]
(STARTAPP "regsvr32.exe"
          (STRCAT "/s \"" (FINDFILE "axdb15.dll") "\"")
)



added:
...
then try the previous again.

Not sure if this is what you were looking for, but


33

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #39 on: February 19, 2007, 01:48:47 PM »
Oops... just saw your update, so I tried it...

Code: [Select]
Command: (STARTAPP "regsvr32.exe"
(_>           (STRCAT "/s \"" (FINDFILE "axdb15.dll") "\"")
(_> )
33

Command: (setq odbx (if (< (atoi (substr (getvar "acadver") 1 2)) 16)
((_>                    (vla-getinterfaceobject *acad "ObjectDBX.AxDbDocument")
((_>                    (vla-getinterfaceobject *acad
"ObjectDBX.AxDbDocument.16")
((_>                  )
(_>       )
#<VLA-OBJECT IAxDbDocument 037247a8>

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #40 on: February 19, 2007, 01:49:40 PM »
Whhhheeeeee ... !!!
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #41 on: February 19, 2007, 01:55:43 PM »
Alan may change the test to something like :
Code: [Select]
(SETQ *acad (VLAX-GET-ACAD-OBJECT)
      odbx  (IF (< (SETQ acadvers (SUBSTR (GETVAR "acadver") 1 2)) "16")
              (PROGN
                (IF
                  (NOT (VL-REGISTRY-READ
                         "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"
                       )
                  )
                   (STARTAPP "regsvr32.exe"
                             (STRCAT "/s \"" (FINDFILE "axdb15.dll") "\"")
                   )
                )
                (VLA-GETINTERFACEOBJECT *acad "ObjectDBX.AxDbDocument")
              )
              (VLA-GETINTERFACEOBJECT
                *acad
                (STRCAT "ObjectDBX.AxDbDocument" acadvers)
              )
            )
)
« Last Edit: February 19, 2007, 01:57:58 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #42 on: February 19, 2007, 01:56:45 PM »
Whhhheeeeee ... !!!

Translates to :
Try the original routine now Mike.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

M-dub

  • Guest
Re: Find & Replace Script - Quick Question
« Reply #43 on: February 19, 2007, 01:59:57 PM »
Many Thanks, Kerry!

:)

I think I have to have all of the dwg's closed for it to work right.

I'm just about at a good spot to break, then I'll try it.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Find & Replace Script - Quick Question
« Reply #44 on: February 19, 2007, 02:02:54 PM »
I HAVE had issues running DBX when drawings are open, so play safe for now ..
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find & Replace Script - Quick Question
« Reply #45 on: February 19, 2007, 03:35:09 PM »
Mike, been out of the office.
Thanks Kerry.

Updated the code here per Kerry's suggestion.
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.