AQucsaiJr Posted August 18, 2010 Share Posted August 18, 2010 I have this LISP from Tony Tanzillo that can run through a directory of drawings and is supposed to be able to run a program on each drawing, but I cant get this one to work. What I want it to do is call up a script that I have written that exports .dwg to .dgn. All the parameters have been addressed in the script for the conversion. Right now I use a program called EZ Script Pro to run this script through a directory of drawings, but I would like to be able to do it from autocad and not have to open a totally different program to do this. Can someone help me figure out what I am doing wrong in this program and possibly help me figure out how to use Tony Tanzillo Batch program for what I believe is its intended purpose? Thanks. ; Function from Tony Tanzillo Maestro Guru ; (defun browse-folder (msg path / sh fld folderobject result) (vl-load-com) (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ) ) (setq fld (vlax-invoke-method sh 'BrowseForFolder vlax-vbDefaultButton1 msg ; dialogue box message vlax-vbDefaultButton3 ; BIF_NONEWFOLDERBUTTON Bruno Toniutti path ; path start ) ) (vlax-release-object sh) (if fld (progn (setq folderobject (vlax-get-property fld 'Self)) (setq result (vlax-get-property folderObject 'Path)) (vlax-release-object fld) (vlax-release-object folderobject) result ) ) ) ; ; (defun list-dwg (path / file_list full_list) (setq file_list (vl-directory-files path "*.dwg" 1) ) (setq file_list (mapcar (function (lambda (x) (strcat path "\\" x))) file_list ) full_list (append full_list file_list) ) full_list ) ; ; (prompt "\n********************************************") (prompt "\n Enter OPB to run batch file operation\n") (prompt "\n********************************************") ; ; (defun C:dgnex (/ *good-files* acapp adoc file_obj full-names-list osd) (alert "\nPlease wait a minute \nto ending of batch file operation" ) (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" "w:\\Projects\\")) ) ; change on your start path folder (progn (mapcar (function (lambda (i) (progn (setq file_obj (vla-open (vla-get-documents acapp) i)) (setq *good-files* (cons file_obj *good-files*)) [color=red] [/color][color=red] ;;here will your batch function: (COMMAND "_SCRIPT" "DGNEXPORT.scr" ) ;;My script.[/color] (vla-setvariable file_obj "mirrtext" 0) ; (vla-setvariable file_obj "insunits" 0) ; (vla-setvariable file_obj "annotativedwg" 0) (vla-close file_obj :vlax-true) (vlax-release-object file_obj) (setq file_obj nil) ) ) ) full-names-list ) (cond ((zerop (length *good-files*)) (princ "\nThere isn't opened files\n") ) ((not (eq (length full-names-list) (length *good-files*))) (princ "\nSome files is not opened\n") ) (T nil) ) ) (princ "\nThere isn't .DWG files in selected directory\n") ) (vla-setvariable adoc "SDI" osd) (vla-setvariable adoc "LISPINIT" olsp) (vla-endundomark adoc) (princ) ) Quote Link to comment Share on other sites More sharing options...
AQucsaiJr Posted August 18, 2010 Author Share Posted August 18, 2010 I have changed how I was calling up the dgnexport and now it converts the first drawing in the directory fine but keeps trying to convert the drawing I started the program in... I feel like I am a little closer. ; Function from Tony Tanzillo Maestro Guru ; (defun browse-folder (msg path / sh fld folderobject result) (vl-load-com) (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ) ) (setq fld (vlax-invoke-method sh 'BrowseForFolder vlax-vbDefaultButton1 msg ; dialogue box message vlax-vbDefaultButton3 ; BIF_NONEWFOLDERBUTTON Bruno Toniutti path ; path start ) ) (vlax-release-object sh) (if fld (progn (setq folderobject (vlax-get-property fld 'Self)) (setq result (vlax-get-property folderObject 'Path)) (vlax-release-object fld) (vlax-release-object folderobject) result ) ) ) ; ; (defun list-dwg (path / file_list full_list) (setq file_list (vl-directory-files path "*.dwg" 1) ) (setq file_list (mapcar (function (lambda (x) (strcat path "\\" x))) file_list ) full_list (append full_list file_list) ) full_list ) ;;------------------------------------------------------- ;;DGNEXPORT Function ;;Author: Andrew Qucsai Jr. ;;Date: 08-18-2010 (defun dgnfun ( ) (command "-dgnexport" "v8" "" "master" "standard" "W:\\AutoCAD\\PGE_CUI\\V8-Imperial-Seed3D.dgn" ) (PRINC) ) ;;------------------------------------------------------- ; ; (prompt "\n********************************************") (prompt "\n Enter OPB to run batch file operation\n") (prompt "\n********************************************") ; ; (defun C:dgnex (/ *good-files* acapp adoc file_obj full-names-list osd) (alert "\nPlease wait a minute \nto ending of batch file operation" ) (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" "w:\\Projects\\")) ) ; change on your start path folder (progn (mapcar (function (lambda (i) (progn (setq file_obj (vla-open (vla-get-documents acapp) i)) (setq *good-files* (cons file_obj *good-files*)) ;;here will your batch function: (progn (dgnfun)) ;;My Function (vla-setvariable file_obj "mirrtext" 0) ; (vla-setvariable file_obj "insunits" 0) ; (vla-setvariable file_obj "annotativedwg" 0) (vla-close file_obj :vlax-true) (vlax-release-object file_obj) (setq file_obj nil) ) ) ) full-names-list ) (cond ((zerop (length *good-files*)) (princ "\nThere isn't opened files\n") ) ((not (eq (length full-names-list) (length *good-files*))) (princ "\nSome files were not opened\n") ) (T nil) ) ) (princ "\nThere isn't .DWG files in selected directory\n") ) (vla-setvariable adoc "SDI" osd) (vla-setvariable adoc "LISPINIT" olsp) (vla-endundomark adoc) (princ) ) Quote Link to comment Share on other sites More sharing options...
SteveK Posted August 18, 2010 Share Posted August 18, 2010 Hi, I'm not certain, but isn't it something to do with not being able to use command? I remember asking something similar a while ago but with batch importing. Quote Link to comment Share on other sites More sharing options...
AQucsaiJr Posted August 18, 2010 Author Share Posted August 18, 2010 Hmm... Didnt think of that. I might be going about this all wrong in that case. Quote Link to comment Share on other sites More sharing options...
SteveK Posted August 18, 2010 Share Posted August 18, 2010 I don't have autocad to check, but I'd be interested to know if it works on anything that doesn't use command. Quote Link to comment Share on other sites More sharing options...
AQucsaiJr Posted August 18, 2010 Author Share Posted August 18, 2010 Lee Mac helped me use this program to write a batch text replace program a while back, but that did not use command. Quote Link to comment Share on other sites More sharing options...
AQucsaiJr Posted August 18, 2010 Author Share Posted August 18, 2010 I think your right. I do believe that part of the problem is the use of command. I think I can get around that if I could find where autocad places the dgnexport LISP function and place it within my program. That way I do not have to use command, I could use progn. Does anyone know where I can find the actual dgnexport program that autocad is using? Quote Link to comment Share on other sites More sharing options...
SteveK Posted August 18, 2010 Share Posted August 18, 2010 I don't think you'll find it. Aren't only some of the express tools as lisps? I hope I'm wrong, but I'd say if you don't have microstation you'll have to stick with that EZ script Pro (which sounds pretty neat if it does the job already). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.