October 31, 2017

ACA: Start Tab and New Drawing Files

This most likely applies to "plain" AutoCAD® and all verticals built on AutoCAD. The Start tab has been there for quite a few releases so far, but somehow I only figured the following out recently, so I thought I would document it here for anyone else who is unaware of it. I almost always start AutoCAD® Architecture from a desktop shortcut, and then start and leave open a blank, new drawing ("Drawing1"). This is an old habit - many releases back, settings would get lost if you closed the program in a "zero-doc" state (no open drawings), so I got in the habit of leaving the initial drawing that opened when starting the program from a shortcut (before the New/Start tab was added), as I like to save and close my working files manually, rather than relying on the program to prompt me to save any unsaved files if I were to close the program with working files open. (I have a lot of little habits like that - otherwise, I am perfectly normal.)

Anyway, now that the Start tab is there on startup, I usually create a new file from my default template, and had been using the Templates drop-down list to choose a template.
Here at home, the list of templates is pretty long, but the last template used has the initial highlight, making it semi-easy for me to select it again most of the time. At work, the list is much shorter, making it even easier to get the right one. I had been doing that for years, until I discovered that the Start Drawing rectangular area just above the Templates drop-down list is not just pretty graphics - it is a giant button, and will start a new drawing with the template assigned as the QNEW template in the Options dialog for the current AutoCAD Profile. That is the template I use for Drawing1 99.99% of the time anyway, so now I can save at least three to four seconds and a click every time I start the program by clicking on that button instead of using the drop-down list.

PS. Yes, I see the notification that I have three product updates. I checked, and they are for various versions of Revit®. I promise to download and install them soon.

October 21, 2017

ACA: Using AutoLISP to Change the Heights of All Doors of a Given Style

There was a request in the AutoCAD® Architecture Forum for a script or customization that could change the heights of all Doors of a specific style to 5'-2". I decided that would be an interesting challenge, and decided to see if I could come up with an AutoLISP® function that would to just that. The exact style name was not given, and I may not have had a style of that name, anyway, so I decided to set up my test file with several instances of the out-of-the-box Bifold - Single Door Style, along with some other Doors.

The routine first gets all of the Doors in the drawing file. If none are found, an alert message is displayed, and the function terminates. If Doors are found, the function iterates over that selection set of all Doors, one Door at a time, looking for Doors of the Bifold - Single Door Style. When one is found, its Height property is changed to 62.0. When all of the Doors have been examined, the program reports that it is complete and lets the user know how many Doors had their height set to 62.0, of the total number of Doors. The routine does not check to see if the height is already 62.0, so it will report the total number of Bifold - Single Doors as being processed. If it were important to report on the number of Doors that actually were changed, the current height could be obtained and compared against the desired height, and any Doors that were already set to the desired height could be skipped.
(defun C:DRHT (                         ; No arguments.
                iCount                  ; Loop counter [integer].
                iMax                    ; Total number of Doors in file [integer].
                iProc                   ; Number of Doors processed [integer].
                objDoor                 ; Door object being processed.
                ss1                     ; All Doors in the file [selection set].
                sStyleName              ; Style name of Door being processed [string].
              ) ;_ End arguments and local variables.
  (setq        ss1 (ssget "_X" '((0 . "AEC_DOOR"))))
    ((not ss1)                          ; No Doors in drawing.
     (alert "Drawing file has no Door objects.\nNothing to do!")
    ) ;_ End condition A1.
    (T                                  ; Else, continue.
     (setq iMax          (sslength ss1)
           iCount 0
           iProc  0
     ) ;_ End setq.
     (while (< iCount iMax)
       (setq objDoor    (vlax-ename->vla-object (ssname ss1 iCount))
             sStyleName (vlax-get-property objDoor 'StyleName)
       ) ;_ End setq.
       (if (= sStyleName "Bifold - Single")
           (vlax-put-property objDoor 'Height 62.0)
           (setq iProc (1+ iProc))
         ) ;_ End progn.
       ) ;_ End if.
       (setq icount (1+ icount))
     ) ;_ End while.
    ) ;_ End condition A2.
  ) ;_ End cond A.
      "\nDRHT function completed:  "
      (itoa iProc)
      " Door(s) of "
      (itoa iCount)
      " total Door(s) processed. "
    ) ;_ End strcat.
  ) ;_ End prompt.
) ;_ End C:DRHT.

Change the (if (= sStyleName "Bifold - Single") line, replacing "Bifold - Single" with the name of the Door Style you want to operate on (enclosed in double quotes). Change the (vlax-put-property objDoor 'Height 62.0) line, replacing 62.0 with a real number representing the desired Door Height in whatever your current linear drawing unit is (inches, millimeters, etc.). The code could also be modified to remove the Style Name test, if you wanted to reset the heights of all Doors in a project to a specific height.