Arin9916 Posted June 9, 2011 Posted June 9, 2011 i want make plot dwgs in some fold what is wrong? .... .... (mapcar '(lambda (dwg) (setq File (vla-open (vla-get-documents (vlax-get-acad-object)) dwg)) (PTE:plotting2 "cannon2.pc3" "ST eng.ctb" "A4" 1 1 file) ) dwgs ) ,,, ,,, (defun PTE:plotting2( device ctb paper num type acDoc / actLay )(vl-load-com) (setq actLay (vla-get-ActiveLayout acDoc) ;;모형 or layout ) (vlax-invoke-method actlay 'RefreshPlotDeviceInfo) (vla-put-Configname actlay device) ; (vla-put-CanonicalMediaName actlay paper) ; (vla-put-PaperUnits actlay 1) (vla-put-PlotRotation actlay 1) (vla-put-PlotType actlay type) (vla-put-StandardScale Actlay acScaleToFit) (vla-put-UseStandardScale actlay :vlax-true) (vla-put-CenterPlot actlay :vlax-true) (vla-put-PlotWithPlotStyles actlay :vlax-true) ; (vla-put-StyleSheet actlay ctb) ; (vla-put-PlotHidden actlay :vlax-false) (vla-put-NumberOfCopies (vla-get-Plot acdoc) num) (if (= type 4) (vla-GetWindowToPlot actLay p1 p2)) (vla-PlotToDevice (vla-get-Plot acDoc)) ;(vla-PlotToFile (vla-get-plot acdoc) (strcat (getvar "DWGPREFIX") (vl-filename-base (getvar "DWGNAME")) ".PDF")) ) Quote
Lee Mac Posted June 9, 2011 Posted June 9, 2011 Assuming the subfunction "PTE:plotting2" works, I would suggest calling it from a script and use the script to open/close the drawings. Quote
Arin9916 Posted June 9, 2011 Author Posted June 9, 2011 always.. thanks to lee-mac... i want open the file read-only.... how can i open the file (read-only) using script...? and i study visual-lisp now.. i need to want what problum this source...? Quote
Lee Mac Posted June 9, 2011 Posted June 9, 2011 always.. thanks to lee-mac...i want open the file read-only.... how can i open the file (read-only) using script...? and i study visual-lisp now.. i need to want what problum this source...? Why do need to open it read-only to print it? Just open it and don't save it. Quote
Arin9916 Posted June 9, 2011 Author Posted June 9, 2011 someone always open the my file via network if already open the file then my script source is error and i use your subroutine. thanks. below is example source.. (defun c:zoome() (PTE:script "zoom e" T nil) ) (defun PTE:script( cmd save first / directory dwgs dwg scr-name f ) ;;______________________________________________________________ Sub Function - 01 (defun LM:GetAllFiles ( Dir Subs Filetype / GetSubFolders ) ;; ? Lee Mac 2010 (defun GetSubFolders ( folder / _f ) (mapcar (function (lambda ( f ) (setq _f (strcat folder "\\" f)) (cons _f (apply (function append) (GetSubFolders _f))) ) ) (cddr (vl-directory-files folder nil -1)) ) ) (apply (function append) (vl-remove (quote nil) (mapcar (function (lambda ( Filepath ) (mapcar (function (lambda ( Filename ) (strcat Filepath "\\" Filename) ) ) (vl-directory-files Filepath Filetype 1) ) ) ) (append (list Dir) (apply (function append) (if subs (GetSubFolders Dir)))) ) ) ) ) ;;______________________________________________________________ Sub Function - 02 (defun LM:directoryDialog ( msg dir flag / Shell HWND Fold Self Path ac ) (vl-load-com) ;; ? Lee Mac 2010 (setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application") HWND (vl-catch-all-apply 'vla-get-HWND (list ac)) Fold (vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND) msg flag dir)) (vlax-release-object Shell) (if Fold (progn (setq Self (vlax-get-property Fold 'Self) Path (vlax-get-property Self 'Path)) (vlax-release-object Self) (vlax-release-object Fold) (and (= "\\" (substr Path (strlen Path))) (setq Path (substr Path 1 (1- (strlen Path))))) ) ) Path ) (setvar "cmdecho" 0) (setq directory (LM:directoryDialog ".........." nil 1)) (if (eq "\\" (substr directory (strlen directory))) (setq directory (substr directory 1 (1- (strlen directory)))) ) (setq dwgs(LM:GetAllFiles directory nil "*.dwg")) (setq fname (vl-filename-mktemp "ST-script.scr") f (open fname "w") ) (if first (progn (write-line "_.QSAVE" f) (write-line "_.CLOSE" f) ) ) (foreach dwg dwgs (progn (write-line (strcat "_.OPEN \"" dwg "\"") f) (write-line cmd f) (if save (write-line "_.QSAVE" f)) (write-line "_.CLOSE" f) ) ) (close f) (command "_.SCRIPT" fname) (vl-file-delete fname) (princ) ) Quote
Lee Mac Posted June 9, 2011 Posted June 9, 2011 Please use CODE Tags when posting code: [noparse] Your Code Here [/noparse] Read this. Quote
Lee Mac Posted June 9, 2011 Posted June 9, 2011 With regards to the Script, you may find this program of use: http://lee-mac.com/scriptwriter.html Quote
Arin9916 Posted June 9, 2011 Author Posted June 9, 2011 thanks for advice. lee-mac:) i use wscript but it`s same problum;; if i already open the file and run script then prompt this message "Would you like to open the file read-only? " ;;; Quote
Lee Mac Posted June 9, 2011 Posted June 9, 2011 Maybe check to see if its open first, then if so, say yes to the prompt: To check if a file is open (findfile (strcat <FilePath> <Filename> ".dwl")) Quote
Arin9916 Posted June 9, 2011 Author Posted June 9, 2011 actually i think find "*.dwl" before but if autocad close with error (ctrl+alt+del) dwl file remain.. of course remove file then no problum. script lisp is so important in my work because, i deal with many dwg. so i want to make perpect script lisp just my greed. i need to study more.. and thinks to leemac. you`re kind man Quote
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.