Michael's Corner is a monthly publication written by Michael E. Beall, Autodesk Authorized Author and peripatetic AutoCAD trainer. Michael travels all over the USA, bringing his fantastic experience and great understanding of AutoCAD to his clients. Michael's Corner brings together many of the tips, tricks and methods developed during these training sessions for the benefit of all users.
Michael's Corner provides something for every AutoCAD user. Every month, a number of articles cover a wide range of topics, suitable for users at all levels, including "The Basics" for those just starting out. Essentially, the aim of Michael's Corner is to help all AutoCAD users work smarter and faster.
It's a God-thing.
I had no idea that 14 years ago I would be given the opportunity to make an impact on the professional lives of so many. Only God knew what was ahead, and hopefully, the contributions I have made through Michael's Corner have equipped many of you to be more productive and a bit more savvy using AutoCAD. And apart from all the AutoCAD bashing that is going on, I'm sure it has a long life ahead.
So, in an effort to keep the AutoCAD fires burning, here's what I have for my final installment…
…A reminder on how to customize your hot keys
…Three Power Tools — one for Zoom, one for editing, and one for Layers
…Two Odd Spots — one for Layers and one for Hatching
…Buried text treasure
…And how to Search 14 years of the Archives
As for what's ahead for me, I will continue to present a variety of AutoCAD sessions — Fundamentals, Intermediate, Customizing, Updates, and 2D & 3D. I will also keep training CAP Designer, 20-20 Worksheet, Visual Impression (those three from 20-20 Technologies, Inc.), and some Revit Fundamentals. Next year I'm looking forward to being very involved in training CET (from Configura, Inc.) when Herman Miller joins the growing number of manufacturers embracing this software that is being touted as the ‘Future of Space Planning’. Personally, I'm looking forward to spending a bit more time with Donna, my lovely bride of 30 years. When this posts, we'll probably be within days of going on our 30th Anniversary vacation to the Tanque Verde Ranch in Tucson; Ee-Hah! We had such a good time when we went for our 20th, we figured we'd do it again!
Ah, and I'm hoping to have The AutoCAD Workbench, Final Edition out before snow flies.
And with that, Mike drop! …so to speak.
The LORD bless you and keep you;
The LORD make His face shine upon you,
And be gracious to you;
The LORD lift up His countenance upon you,
And give you peace. Numbers 6:24-26
Reference file: Batch Draw Order.lsp
Being able to batch process a set of drawings is very powerful and being able to control things like draw order across many drawings is even more powerful. The following AutoLISP routine while on the advanced side, moves single line and multiline text to the very top in the draw order. This allows you to make sure that text is always drawn last, so if you have text that contains a fill it is always drawn above other objects in your drawing. I have included comments for each line of code and what it does.
;; Loads the Visual LISP library (vl-load-com) ;; Creates a new command named BatchDrawOrder (defun c:BatchDrawOrder ( / sDWGFolder sDWGFiles acadApp docsColl sFile dwgObj modelSpaceextDict sortentsTable cnt acObject lstTemp lstObjects cntStep) ;; Set the folder to update the drawings in (change this to the folder you want to process) (setq sDWGFolder "c:\\test") ;; Get the list of DWG files in the folder (setq sDWGFiles (vl-directory-files sDWGFolder "*.DWG" 1)) ;; Get the AutoCAD application object (setq acadApp (vlax-get-acad-object)) ;; Get the Documents collection (setq docsColl (vla-get-documents acadApp)) (foreach sFile sDWGFiles (progn ;; Open the drawing file (setq dwgObj (vla-open docsColl (strcat sDWGFolder "\\" sFile) :vlax-false)) ;; Get the Model Space object for the Drawing (setq modelSpace (vla-get-modelSpace dwgObj)) ;; Get the Extension Dictionary for Model Space (setq extDict (vla-getExtensionDictionary modelSpace)) ;; Check to see if the Sortents Table exists in the drawing (if (= (type (setq sortentsTable (vl-catch-all-apply 'vlax-invoke-method (list
extDict 'Item "ACAD_SORTENTS")))) 'VL-CATCH-ALL-APPLY-ERROR) (setq sortentsTable (vla-addObject extDict "ACAD_SORTENTS" "AcDbSortentsTable")) ) ;; Set counter for single line and multiline text to zero (setq cnt 0 lstObjects nil) ;; Loop through the ModelSpace collection (vlax-for acObject modelSpace ;; Check to see if the object is a text object (if (or (= (vla-get-objectName acObject) "AcDbText")(= (vla-get-objectName
acObject) "AcDbMText")) (progn ;; Adjust the array based on the number of objects in the drawing (if (>= cnt 1) (progn ;; Get the current values in the array and then adjust the size (setq lstTemp lstObjects) (setq lstObjects (vlax-make-safearray vlax-vbObject (cons 0 cnt))) ;; Step through the old array values and load them into the new array (setq cntStep 0) (repeat cnt (vlax-safearray-put-element lstObjects cntStep (vlax-safearray-get-element
lstTemp cntStep)) (setq cntStep (1+ cntStep)) ) ) (setq lstObjects (vlax-make-safearray vlax-vbObject '(0 . 0))) ) ;; Add the text object to the array and increment counter by 1 (vlax-safearray-put-element lstObjects cnt acObject) (setq cnt (1+ cnt)) ) ) ) ;; If the array is not empty then adjust the Draw Order value for the text objects (if (/= lstObjects nil) (progn (vla-moveToTop sortentsTable lstObjects) ;; Save the changes to the drawing (vla-save dwgObj) ) ) ;; Close the drawing and go to the next one (vla-close dwgObj) ) ) (princ) )