Message 1 of 6

Not applicable
09-17-2015
10:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I made a first draft of my lisp. By cons I can not filter the list of models with the elements in each of the current directory files. (Part 2).
Currently the lisp below, having updated the open drawing, second insert portion all blocks of the list of models in drawings. I think it lacks a focus after the opening of the files in the directory to execute commands on each of the open files. Set (;;; ==== DOESNT WORKS) in the lisp.
Thank you in advance for your help.
(vl-load-com) (defun folderbox1 (message / sh folder result) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application")) (setq folder (vlax-invoke-method sh 'browseforfolder 0 message 0)) (vlax-release-object sh) (if folder (progn (setq result (vlax-get-property (vlax-get-property folder 'self) 'path)) (if (wcmatch result "*\\") result (strcat result "\\") ) ) ) ) (defun Ouvrir_dessin_dbx1 (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 ) (defun c:test ( / dir files f b ) ;;;---diallogbx (if (setq dir (folderbox1 "Selectionner un dossier avec des gabarits") files (vl-directory-files dir "*.dwg" 1) ) (progn (foreach f files (if (tblsearch "block" (vl-filename-base f)) (progn (setq fichier (strcat dir "\\" f)) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object))) (setq mspace2 (vla-get-modelspace thisdrawing)) (setq obj2 (vla-InsertBlock mspace2 (vlax-3d-point '(0 0 0)) fichier 1 1 1 0 )) ;(tblsearch "block" (setq b (vl-filename-base f))) (vla-delete obj2) ))) (princ (strcat "\n...Dessin courant...ok (!) actualiser avec regen" "\n"))(princ) )) ;;; (2ème partie) ;;;---liste des dessins du repertoire (setq rep (substr (getvar "dwgprefix") 1 (1- (strlen (getvar "dwgprefix"))))) (if (setq lst (vl-directory-files rep "*.dwg" 1)) (progn (and (eq (strcase rep) (strcase (substr (getvar "dwgprefix") 1 (1- (strlen (getvar "dwgprefix")))))) (setq lst (vl-remove (getvar "dwgname") lst)) ) (progn ;;;---for each liste du dossier courant (foreach fic lst (princ (strcat "\n...Ouverture sur " fic "...ok \n"))(princ) (if (setq dbx (ouvrir_dessin_dbx1 (strcat rep "\\" fic))) (progn ;;;---for each du dossier des modèles choisis (foreach f (vl-directory-files dir "*.dwg" 0) ;;;==== DOESNT WORKS (if (tblsearch "block" (vl-filename-base f)) (progn (setq fichier1 (strcat dir f)) (progn (setq sp1 (vla-get-ModelSpace dbx)) (setq obj1 (vla-InsertBlock sp1 (vlax-3d-point '(0 0 0)) fichier1 1 1 1 0 )) (vla-delete obj1) ) ) ) ;;;===== DOESNT WORKS) (princ (strcat "\n...Sauvegarde sur " fic "...ok \n"))(princ) (vla-saveas dbx (strcat rep "\\" fic)) (vlax-release-object dbx) ) ) ) ) ) ) )
Solved! Go to Solution.