PDA

View Full Version : Recoverall & Setbylayer for multiple files


ajtrahan
2008-07-23, 07:31 PM
Hello programers,

I am curious to know if there is a way to use the recoverall cmd for multiple files w/o having to open each file. I have 20 base files with 10-30 xrefs in them created in AC 06. I use the recoverall cmd in AC 2009 to save my base files as AC 07 version. It is a great tool but I thing it would be a better tool if someone could create a routine or whatever to allow you to select multiple files. I don't know how, would love to learn, that's why I'm here. The reason I convert them to 07 format is to use the setbylayer cmd.

I would also love to know if there is a way to do the same thing with the setbylayer cmd. Have it open multiple files, thaw and unlock layers and then select all and change by layer and then relock and freeze layers.

We use ADT 06 and sometimes change the properties of an object instead of putting it on the correct layer. Our MEPS consultants use our base files as a background and complain that not all of the objects are bylayer.

Thanks!
Jason

ccowgill
2008-07-23, 07:38 PM
Hello programers,
... The reason I convert them to 07 format is to use the setbylayer cmd.
...
why not just run a script and have it run the setbylayer command, then save the drawing, I do not see the reason to have the additional step of converting them to 07 format. We ran a script through our Eagle Point block library and didnt have a bit of trouble.

here is the lisp to create the script:

(defun c:Bb (/ UserFile UserDir FileList File#1 DwgName FileName )
(vl-load-com)
(setq UserFile (getfiled "Select a drawing within the directory to process" "" "dwg" 16 ) )
(setq UserDir (vl-filename-directory UserFile ) )
(setq FileList (vl-directory-files UserDir "*.dwg" 1 ) )
(setq File#1 (open "c:/BatchRun.scr" "w" ) )
(foreach DwgName FileList
(setq FileName (strcat "\"" UserDir "\\" DwgName "\"" ) )
(princ "open\n" File#1 )
(princ (strcat FileName "\n" ) File#1 )
(princ "(command \42._SETBYLAYER\42 \42ALL\42 \42\42 \42y\42 \42Y\42 )\n" File#1 )
(princ "_.close\n" File#1 )
(princ "N\n" File#1 ) ; do save
)
(close File#1 )
(command "._delay" "3000" ) ; wait ~3 sec to let file close
(command "._script" "C:/BatchRun.scr" )
(princ)
)
it does not have the ability to unlock, thaw, freeze and lock layers

ajtrahan
2008-07-23, 07:53 PM
Thanks. I'll give it a try. edit: Works great!

The reason I do a recoverall is to use the setbylayer cmd. AC 09 kept asking to recover the 04 version drawings. recoverall allows me to recover the drawing and save as an 07 version.

Jason

patrick35
2008-07-24, 04:20 PM
Hi

If you want to choose a directory to avoid using getfiled

(defun dirbox(/ cdl rep)
(if (setq cdl (vlax-create-object "Shell.Application"))
(progn
(and (setq rep (vlax-invoke cdl 'browseforfolder 0 "Select a directory" 512 ""))
(setq rep (vlax-get-property (vlax-get-property rep 'self) 'path))
)
(vlax-release-object cdl)
)
)
rep
)

@+

ajtrahan
2008-07-25, 01:38 AM
Hi

If you want to choose a directory to avoid using getfiled

(defun dirbox(/ cdl rep)
(if (setq cdl (vlax-create-object "Shell.Application"))
(progn
(and (setq rep (vlax-invoke cdl 'browseforfolder 0 "Select a directory" 512 ""))
(setq rep (vlax-get-property (vlax-get-property rep 'self) 'path))
)
(vlax-release-object cdl)
)
)
rep
)

@+

Do I need to combine the two? If so how?

Thanks.

patrick35
2008-07-25, 09:42 AM
I don't know ._SETBYLAYER, but if I understand your request, a lisp, which avoids using scripts

(defun c:bd(/ bl dbx fic lst obj rep
msgbox dirbox ouvrir_dessin_dbx)

(defun msgbox (Titre Bouttons Message / Reponse WshShell)
(vl-load-com)
(setq WshShell (vlax-create-object "WScript.Shell"))
(setq Reponse (vlax-invoke WshShell 'Popup Message 0 Titre (itoa Bouttons)))
(vlax-release-object WshShell)
Reponse
)

(defun dirbox(/ cdl rep)
(if (setq cdl (vlax-create-object "Shell.Application"))
(progn
(and (setq rep (vlax-invoke cdl 'browseforfolder 0 "Select a directory" 512 ""))
(setq rep (vlax-get-property (vlax-get-property rep 'self) 'path))
)
(vlax-release-object cdl)
)
)
rep
)

(defun ouvrir_dessin_dbx(dwg / dbx)
(if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
(setq dbx (vlax-create-object "ObjectDBX.AxDbDocument"))
(setq dbx (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))))
)
(vla-open dbx dwg)
dbx
)

(if (setq rep (dirbox))
(if (setq lst (vl-directory-files rep "*.dwg" 1))
(foreach fic lst
(setq dbx (ouvrir_dessin_dbx (strcat rep "/" fic)))
(princ (strcat "\nWorking " fic))
(vlax-for bl (vla-get-blocks dbx)
(vlax-for obj bl
(vl-catch-all-apply 'vla-put-color (list obj acByLayer))
)
)
(vla-saveas dbx (strcat rep "/" fic))
(vlax-release-object dbx)
(princ " OK")
)
(msgbox "BD" 64 (strcat "No file in " rep))
)
)
(princ)
)

@+

ajtrahan
2008-07-25, 04:44 PM
Patrick35,

This works great in ADT 06. Thanks.

After a little testing I noticed it did not change the settings of attributes in a block nor did it unlock layers, change the objects and lock the layer back. It did however change the objects on frozen layers.

I got an error in AC 09:
Command: ap APPLOAD Patrick35.lsp successfully loaded.
Command: bd ; error: no function definition: VLAX-CREATE-OBJECT

This is just feedback don't feel obligated to change anything for me.

Thanks again,
Jason

patrick35
2008-07-28, 08:54 AM
error: no function definition: VLAX-CREATE-OBJECT
I've forgotten (vl-load-com)
This is repaired.

it did not change the settings of attributes in a block
I had not thought is in the new version.

(defun c:bd(/ att ava bl dbx express fic lay lst obj rep tot ver
msgbox dirbox ouvrir_dessin_dbx)

(defun msgbox (Titre Bouttons Message / Reponse WshShell)
(setq WshShell (vlax-create-object "WScript.Shell"))
(setq Reponse (vlax-invoke WshShell 'Popup Message 0 Titre (itoa Bouttons)))
(vlax-release-object WshShell)
Reponse
)

(defun dirbox(/ cdl rep)
(if (setq cdl (vlax-create-object "Shell.Application"))
(progn
(and (setq rep (vlax-invoke cdl 'browseforfolder 0 "Select a directory" 512 ""))
(setq rep (vlax-get-property (vlax-get-property rep 'self) 'path))
)
(vlax-release-object cdl)
)
)
rep
)

(defun ouvrir_dessin_dbx(dwg / dbx)
(if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
(setq dbx (vlax-create-object "ObjectDBX.AxDbDocument"))
(setq dbx (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))))
)
(vla-open dbx dwg)
dbx
)

(vl-load-com)
(if (member "acetutil.arx" (arx))
(setq express T)
)
(if (setq rep (dirbox))
(if (setq lst (vl-directory-files rep "*.dwg" 1))
(foreach fic lst
(setq dbx (ouvrir_dessin_dbx (strcat rep "/" fic))
ver nil
tot 0
ava 0
)
(vlax-for lay (vla-get-layers dbx)
(and (eq (vla-get-lock lay) :vlax-true)
(setq ver (cons lay ver))
(vla-put-lock lay :vlax-false)
)
)
(and express
(vlax-for bl (vla-get-blocks dbx)
(setq tot (+ tot (vla-get-count bl)))
)
(acet-ui-progress-init "" tot)
)
(princ (strcat "\nWorking " fic))(princ)
(vlax-for bl (vla-get-blocks dbx)
(vlax-for obj bl
(and express
(setq ava (1+ ava))
(acet-ui-progress-safe ava)
)
(vl-catch-all-apply 'vla-put-color (list obj acByLayer))
(and (eq (vla-get-objectname obj) "AcDbBlockReference")
(foreach att (vlax-invoke obj 'getattributes)
(vl-catch-all-apply 'vla-put-color (list att acByLayer))
)
)
)
)
(foreach lay ver
(vla-put-lock lay :vlax-true)
)
(and express
(acet-ui-progress-done)
)
(princ " Save")(princ)
(vla-saveas dbx (strcat rep "/" fic))
(vlax-release-object dbx)
(princ " OK")(princ)
)
(msgbox "BD" 64 (strcat "No file in " rep))
)
)
(princ)
)

@+

ajtrahan
2008-07-28, 10:00 PM
Thanks again Patrick!

This does everything I could ask for. Do you mind if I share it?

Regards,
Jason

patrick35
2008-07-29, 08:26 AM
Do you mind if I share it?
Yes, you can. It's free.

@+