Jump to content

Recommended Posts

Posted

Hi guys as you can tell this is my first post and any help that you can give would be greatly welcomed. I have a lisp that some one at my offis has made that will delete a block a a give corodance and replace with a new block. This works on the selected dirrectory. What I would like to do is change it to ask to make a selection of the block to deleted. Here is the Lisp as it stands..

 

Thanks again.

 

 

(defun c:PasteAll

(/ UserFile UserCat FileList File#1 DwgName FileName Replace)

(vl-load-com)

(setq Replace (getstring "\nAre we Replacing this time?"))

(setq UserFile

(getfiled "Select a drawing within the directory to process"

"z:/"

"dwg"

16

)

)

(setq UserCat (vl-filename-directory UserFile))

(setq FileList (vl-directory-files UserCat "*.dwg" 1))

(setq File#1 (open "c:/Pasteall.scr" "w"))

;; open/make a scriptfile to write to

(foreach DwgName FileList

(setq FileName (strcat "\"" UserCat "\\" DwgName "\""))

(princ "open\n" File#1)

(princ (strcat FileName "\n") File#1)

;;Below are commands to run on each drawing...

(princ "_.zoom _e\n" File#1)

(if (= Replace "YES")

(princ "erase\n" File#1))

(if (= Replace "YES")

(princ "168.5,4.5\n" File#1))

(if (= Replace "YES")

(princ "\n" File#1))

;;erase three lines above to remove the delete feature (i.e. adding revision to set)

(princ "purge\n" File#1)

(princ "all\n\n" File#1)

(princ "N\n" File#1)

(princ "audit\n" File#1)

(princ "Y\n" File#1)

(princ "pasteclip\n" File#1)

(princ "0,0\n" File#1)

(princ "_.zoom _e\n" File#1)

(princ "_.qsave\n" File#1)

(princ "_.close\n" File#1)

)

(close File#1)

(command "script" "C:\\Pasteall.scr")

(princ)

)

(princ "\nPasteall loaded.")

(princ)

Posted

2 things

First paste code correct way moderator wiil be on to this soon use the # option and paste code between [ code] paste here [ /code]

 

I would have the script part only create a file list and then have the process as preloaded lisp say first line in script, this way you can test your lisp before running a script.

 

using princ ... file#1 maybe should be writeline this would be a more consistant programming method at a higher level see readline also. I would probably use a entsel for an object at this co-ord and check its a block then delete it, then insert new block.

 

Others may totaly disagree its often the way with Autocad more than one method.

 

script 
(load "myeraseblock")  this would ask the question name of block first time only and write the script as per next line
open dwg1 (kd:myeraseblock blockname)
open dwg2 (Kd:myeraseblock blockname)

(defun kd:myeraseblock (blockname)
(command "purge" "A" "N")
(command "audit"

and so on
)

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...