Tipniques: Phase Modifiers

Back in 2008 I taught a class at Autodesk University named, “Efficient CAD Management through Customization”.  In this class I discussed creating programming for AutoCAD that works behind the scenes.  Whenever a button is clicked, a command typed or a palette command is selected, the programming, in the background, will change to the correct layer, insert the block at the correct scale, etc…  One of the developments I have made since then is what I like to call Phase Modifiers.  This is what I’m going to discuss in this article.

In order to make this type of programming work, you need to already have programming in place.  If you are unsure how to achieve this, my handout from AU2008 can help you.  This handout can be found on my LinkedIn public profile under Publications.  You can find my LinkedIn public Profile at the bottom of this article.  This will walk you through utilizing the ACAD.LSP to run your programming at the start of every drawing in conjunction with the profile, menus and Tool Palettes.

Since I have worked with Revit for the past six years I used a lot of phasing.  I had to think about it more than I did with AutoCAD.  So, I realized that I could use phasing in AutoCAD as well.  The concept is simple, use programming to make it possible to click on a button or tool in the palette and have that object come in at the right layer, linetype, etc…

The first task to completing this is to add the programming to your ACAD.LSP.  To make it a little more simple, I have just used New or Exist for this article.  This is what it would look like in your ACAD.LSP:

(setvar "CMDECHO" 0)
(if (= nil NORE)
(setvar "CMDECHO" 1)

I chose NORE for the variable, but you can make it whatever you like.  This is the variable that will be read throughout the AutoCAD drawings.  Either you set it to “NEW” or “EXIST” depending on the LISP routine that you are running.  In the above text, initially, if the variable has not been set for the drawing you are opening, it sets the variable to new.  After you add this text to your ACAD.LSP, it is necessary to produce LISP routines for separate phases.  For example, if I want to create a routine that will react to the phase modifier and choose the correct Hatch, I would have to make programming to facilitate that.  Currently, I have another modifier that I use that changes what the hatch or object would be, per discipline.  So, I would create three different types of LISP routines.  The first routine would read which phase is active:

(defun C:CrossHatch (/ o:la)
   (setvar "cmdecho" 0)
   (setq o:la (getvar "CLAYER"))

   (if (= NORE "NEW")
     (load "J:/General/Support/Separate LISP Routines/CrossHatchNew"))

To save space, I did not put all of the text from the routine.  You would add more lines, with variables, per the phases that you would like to set up in your programming.  The next routine would read which discipline is active:

   (setvar "cmdecho" 0)

   (if (= DISC "ARCH")
     (load "J:/Autodesk/ACADPROD/2012/General/Support/Separate LISP Routines/CrossHatchA"))

Same as above, you can add which disciplines that you would like any hatch or object to differentiate.  After this routine is completed, the last routine would contain the actual command to create the hatch(This routine would have to be duplicated per all of the hatch patterns that you would use per discipline and phase):

   (setvar "cmdecho" 0)
   (setq o:la (getvar "CLAYER"))
     (Setvar "HPASSOC" 1)
     (command "layer" "S" "A-DETL-PATT" "")
     (command "hplayer" "A-DETL-PATT")
     (Command "-Bhatch" "P" "cross" userh "0")
   (setvar "CLAYER" o:la)
     (setvar "cmdecho" 1)

After all of this programming is created, you have to add these routines to your customizations.  I always add my routines to the Ribbons and Tool Palettes.  If you want, you can use these routines at the command line by utilizing the ACAD.PGP, but that’s a lot of commands to remember.  In my opinion, the whole point of customizing is to do more work, more efficiently which means less thought on the command and more thought on what one is actually drawing.  I start with the CUI and add buttons that reflect which phases you are using.  The programming behind these buttons, in the CUI, would read, “^C^C^P(SETQ NORE "NEW") (PRINC)” for new, “^C^C^P(SETQ NORE "EXIST") (PRINC)”, for existing and so on. (See Image 1)

By utilizing a Tool in the Tool Palette that has a command, you can use the following text, for example, in the Command string to run your phase modifier for Hatch: ^C^CCrossHatch

Remember, up above, the first LISP routine that set all of the other routines in motion is named, “CrossHatch”.  Once all of your programming is set in place as we discussed above, the programming will do all of the work for you.  The good thing about creating your programming this way is that you don’t have to load every LISP routine at startup.  Therefore your startup will take less time.  Incidentally, in my ACAD.LSP, I have very few settings that I change and I also have paths to the routines that I want to load through the ACAD.LSP as opposed to all of the text of all of the routines I want to load. (See Image 2)

Appears in these Categories