Jump to content

Edit Batch LISP


AQucsaiJr

Recommended Posts

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

  • AQucsaiJr

    19

  • Lee Mac

    14

  • gilsoto13

    3

  • stevesfr

    2

Just out of curiousity, does this method retain the thumbnails of your drawings?

 

No thumbnails... I have come to realize this is not gonna happen with LISP programs of this type.

Link to comment
Share on other sites

Sorry, code updated, an extra line for the save may be needed as the drawings are opened using the documents collection.

 

 

I get the following error when I try to run program:

 

Command: opb

; error: no function definition: BROWSE-FOLDER

 

I'm shure I don't have something set correctly,but what?

Steve

Link to comment
Share on other sites

I get the following error when I try to run program:

 

Command: opb

; error: no function definition: BROWSE-FOLDER

 

I'm shure I don't have something set correctly,but what?

Steve

 

I'm sorry... because of the copy right permisions on Tony Tanzillo web site, I could not post the entire program here... However it is a free program and if you are interested in useing it you can find the program on his website Here.

 

I belive the program is called 'batch and script at startup', and this particular LISP is the BATCH.lsp in that ZIP file.

What Lee has written replaces part of that BATCH.lsp program. A side by side comparison will show the difference very quickly.

 

Again, I am sorry for the confusion but I don't want to get anyone upset, especially the programmers that design these LISP for people like me for free.

 

On a side note, if Tony Tanzillo frequents this forum or someone could ask him, he could possibly post the entire BATCH.lsp here for everyone.

Link to comment
Share on other sites

I found the BATCH.lsp that Tony Tanzillo wrote. This one has a little extra to it because it has been updated, but this is the LISP I am using.

 

Autodesk Community

The BATCH.zip is in one of the last posts in a download link provided by James Murphy.

Link to comment
Share on other sites

No thumbnails... I have come to realize this is not gonna happen with LISP programs of this type.

 

Yeah, you have to involve Arx/.Net to keep the thumbnails - a bit beyond me at the moment. :geek:

Link to comment
Share on other sites

Yeah, you have to involve Arx/.Net to keep the thumbnails - a bit beyond me at the moment. :geek:

 

No problem... Works perfect as is.

Link to comment
Share on other sites

  • 1 month later...

This is were I wanted to post it...

 

I add this option to this thread... just found it today.. untested by me... but it's published in cadalyst.. so I guess it works.

 

http://www.cadalyst.com/cad/autocad/hot-tip-harry-tips-our-readers-april-2005-5143?print=1

 

It seems to work for text, mtext and attributes also. and nice dialog box features... I think.

Replace Text In Dwgs.DCL

Replace Text In Dwgs.LSP

Link to comment
Share on other sites

This is were I wanted to post it...

 

I add this option to this thread... just found it today.. untested by me... but it's published in cadalyst.. so I guess it works.

 

http://www.cadalyst.com/cad/autocad/hot-tip-harry-tips-our-readers-april-2005-5143?print=1

 

It seems to work for text, mtext and attributes also. and nice dialog box features... I think.

 

 

This program seems to do the same thing only with a much better dialog box to guide you through. I'll take a look at it.

Link to comment
Share on other sites

This program seems to do the same thing only with a much better dialog box to guide you through. I'll take a look at it.

 

 

Doesn't work for me (acad 2008 plain)

error

Command: REID ; error: Automation Error. Problem in loading application

 

tried to look at everything, stumped !

S

Link to comment
Share on other sites

Doesn't work for me (acad 2008 plain)

error

Command: REID ; error: Automation Error. Problem in loading application

 

tried to look at everything, stumped !

S

 

yOU're right...

I took a little while to test it... it and didn´t work, I got the same error until I change the acadver code for that one from Charles Alan Butler in the cadalyst discussion...

http://forums.cadalyst.com/showthread.php?t=6079

 

but then I got another error and the routine dosn´t work yet...

 

Command: reid

Looking for text to replace. Please wait...

 

Cannot find in C:\1paulo\asd\CONS-CIM3.dwg. Probably drawing is open now.

Cannot find in C:\1paulo\asd\CONS-CIM32.dwg. Probably drawing is open now.

Cannot find in C:\1paulo\asd\CONSTRUCTIVOS.dwg. Probably drawing is open now.

Cannot find in C:\1paulo\asd\detalle fosa septica.dwg. Probably drawing is open

now.

Cannot find in C:\1paulo\asd\detalle_cim.dwg. Probably drawing is open now. ;

error: bad argument type: VLA-OBJECT nil

---------------------------------------------

 

So I made a 1/2 hour search oin the web... but even when there are several similar threads in different forums...I couldn´t find a good working lisp...

 

I really don´t need it... but maybe i'LL need it someday...

Link to comment
Share on other sites

If you guys are looking for a batch text replace lisp program then you could fallow the steps in this thread to create the one I am using.

 

Quick Overview:

Just take the attached BATCH.lsp and edit it to include the text replace lisp REPSTRING, as LeeMac describes in this thread.

 

The BATCH.lsp is written by Tony Tanzillo, and I am not sure who wrote the REPSTRING but LeeMac has edited it for me and it works great.

 

The BATCH.lsp tells you where to put the program you want to run in each of the drawings. This BATCH.lsp is written in a way that allows you to use it for more that just a text find and replace tool. You can use any lisp program as long as it is applied correctly within the BATCH.lsp program.

 

Good luck. If I can help any further please let me know.

BATCH.LSP

REPSTRING.LSP

Link to comment
Share on other sites

Ok, I finally decided to give it a try... and just added the missing subroutines here, and this lisp worked perfect.. all words have been replaced in all the fiiles as stated in the subroutine by Lee Mac. It just takes a little time to open each drawing... but it is completely automatic...

 

And also, the thumbnails are still there, the preview is OK in the "open" Dialog box and also the thumbnails in windows explorer are OK..

 

I'll try to use it with other subroutines...

batch find and replace OPB.lsp

Link to comment
Share on other sites

Thanks for the credit Gilsoto - appreciated :)

 

The reason it takes longer to open is that it uses the open method on the documents collection (setting SDI mode), and not ObjectDBX, thus sacrificing speed but retaining thumbnails.

 

Lee

Link to comment
Share on other sites

Credit where credit is due... Thanks Gilsoto... I did not want to make any of the programmers involved angry by posting the full script as I did not know the wright way of handling the credit part... Thanks for posting the completed program.

 

I can say I have been using this program for a while an it is great. I am in the process of adding a user interface to it so I can use it to search and replace more than one string at a time.... Tony's batch script is very powerful, as you can run almost any lisp program, using it, through multiple drawings in a folder.

 

 

Hay Lee, maybe you could add this to your list of programs as it seem every couple weeks there is someone looking for a batch text replace tool, or some other batch tool that could probably be run using Tony's batch program pretty easily.

Link to comment
Share on other sites

Hay Lee, maybe you could add this to your list of programs as it seem every couple weeks there is someone looking for a batch text replace tool, or some other batch tool that could probably be run using Tony's batch program pretty easily.

 

I think I may just do that - if I get a minute after I am satisfied with my Global Attribute Extractor.

 

I might use ObjectDBX over the open method though - for the increased speed :twisted:

Link to comment
Share on other sites

I might use ObjectDBX over the open method though - for the increased speed :twisted:

 

 

I wouldn't have expected any different... 8)

 

Make sure to let me know when you do because I would love to try other options for this process. This is just the best I have found so far.

Link to comment
Share on other sites

  • 5 months later...

Hay Dan

Is there a way to change the path witch the file looks under.

My drawing are stored on are Z drive and when I run the file it looks in the C root. it will not allow me to change the directory.

I am not wanting to replace text just find it "RAH" a text or attribute. There are a 171 drawing I have to go threw.

and I trying to work on the report for this job "HP".

Thanks

Link to comment
Share on other sites

  • 1 year later...
Try this:

 

(defun rstring (old new doc / StringRep)
 (vl-load-com)
 ;; Lee Mac  ~  22.01.10

 (defun StringRep (old new str)
   (while (vl-string-search old str)
     (setq str (vl-string-subst new old str)))
   str)

 (if (not (vl-string-search old new))

   (vlax-for lay (vla-get-layouts doc)
 
     (vlax-for obj (vla-get-Block lay)
       
       (cond (  (and (eq "AcDbBlockReference" (vla-get-ObjectName Obj))
                     (eq :vlax-true (vla-get-HasAttributes obj)))

                (foreach att (vlax-invoke Obj 'GetAttributes)
                  (vla-put-TextString att (StringRep old new (vla-get-TextString att)))))
             
             (  (wcmatch (strcase (vla-get-ObjectName obj)) "*DIMENSION*")
              
                (if (not (eq "" (vla-get-TextOverride obj)))
                  (vla-put-TextOverride obj (StringRep old new (vla-get-TextOverride obj)))))
             
             (  (if (vlax-property-available-p obj 'TextString)
                  (vla-put-TextString obj (StringRep old new (vla-get-TextString obj))))))))
     
     (princ "\n** New String Cannot Contain Old String **"))

 (princ))


;;----------------------------------------------------------------------------------------------
(prompt "\n********************************************")
(prompt "\n    Enter OPB to run batch file operation \n")
(prompt "\n********************************************")



(defun C:OPB (/ *good-files* acapp adoc file_obj full-names-list osd)

  (vl-load-com)

 (setq acapp (vlax-get-acad-object)
       adoc  (vla-get-activedocument acapp))

 (vla-startundomark adoc)
 (setq osd (vla-getvariable adoc "SDI"))
 (vla-setvariable adoc "SDI" 0)
 (setq olsp (vla-getvariable adoc "LISPINIT"))
 (vla-setvariable adoc "LISPINIT" 0)
 
 (if (setq full-names-list (list-dwg (browse-folder "SELECT FOLDER" "C:\\")))
   (progn
     (mapcar
       (function
         (lambda (i)
           (progn
             (if (not (vl-catch-all-error-p
                        (setq file_obj
                          (vl-catch-all-apply (function vla-open)
                            (list (vla-get-documents acApp) i)))))
               (progn
                 (rstring "LINENAME1" "THIS WORKED" file_obj)
                 (vla-save file_obj)
                 (vla-close file_obj :vlax-true)
                 (vlax-release-object file_obj)
                 (setq file_obj nil))
                 
               (princ (strcat "\n** Error Opening File: " i " **"))))))
       
       full-names-list))
   
   (princ "\nThere aren't .DWG files in selected directory\n"))
 
 (vla-setvariable adoc "SDI" osd)
 (vla-setvariable adoc "LISPINIT" olsp)
 (vla-endundomark adoc)
 (princ))

{ Untested }

 

I am using the above code to try to find and replace text in a large amount of drawings. I got it to work as I wanted to, except it will not replace text contained in tables (Bill of Material tables). Is this possible?

 

Edit: Nevermind, I just found bfind.lsp on your website and it does exactly what I need.

Edited by buckfever5
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...