Coding a Dimension Layer Shortcut

      Users share keystroke code to set dimension layers in AutoCAD. September 24, 2006

Question
I used to have a dimension tool button that when pressed would automatically set my dimension layer current. Does anyone know how to create that button again?

Forum Responses
(CAD Forum)
From contributor A:
^C^C_-LA;S;DIMENSIONS;;DIMLINEAR;\\\-LA;S;0;;
The above code will change your current layer to DIMENSIONS, let you run a dim linear command and then change the current layer back to 0. Right mouse click to change the properties of the button. Of course you change the name of the layers in the code to reflect your drawing style.



From contributor B:
Just a couple of rudimentary questions from a toolbar novice here - where do you insert such a code? Does "Dimensions" in the command refer to a particular dimension layer that you use in association with a particular dimstyle?


From contributor C:
^C^C-LA;S;DIM;OFF;H,H1,PL,PL1,PL2,DOTS;;OSNAP;END,INT,MID;-DIMSTYLE;R;DIM4;GRAPHSCR;

This micro turns DIM layer on and makes dimstyle DIM4 current. It also turns certain osnaps off and on. You create new button in acad customize user interface dialog box and associate this micro to that button.



From contributor A:
To contributor B: Yes the "Dimensions" does refer to a layer, but does not refer to a style. You certainly can extend the code to reference a style if you want. Anything is possible.


From the original questioner:
The original code you gave me works great. But, after I place a linear dimension and I right click to restart the command I am getting a bunch of layer options instead of the enter command. My right click is set to enter when nothing is selected. I have tried entering *cancel* to the end of your code to replicate the escape command. That didnít quite work either. Any ideas?


From contributor D:
Copy this code to notepad and save as cld.lsp in your support folder for AutoCAD.
(defun c:cld ()
;define the function
;**********************************************************
;Start of Command Function
(command "-Layer" "Set" "DIMENSIONS" ""
"Dimlinear" pause pause pause
"-Layer" "Set" "0" ""
) ;End Command
;End of Command Function
;*********************************************************
(princ)
;finish cleanly
) ;end of defun

In AutoCAD, go to Tools->AutoLISP->Load and click on Contents where it says StartUp Suite and the Add. Browse to your AutoCAD support folder and select the cld.lsp file and click Add. Restart AutoCAD once you have clicked Ok. This should load the cld lisp file each time AutoCAD starts. Type in cld. This should start your command. Only using toolbar commands was "stepping through" the commands instead of combining them all into one. There may be a way to do what you want through only toolbars, but I suggest learning AutoLISP, which will make your life a lot easier. There are some good books at Barnes and Noble which cover Lisp programming, and you can also find many helpful online websites. You can also create a toolbar button with the macro ^C^C_cld if you don't feel like typing in cld all of the time - I like using short keyboard entries myself. What industry are you in? Do you do any CNC programming? I am in the countertop industry and do CAD and program our CNC. Maybe we can share some ideas.



From contributor D:
Someone emailed me and asked what the code would be if you wanted to change the layer back to the previous layer instead of Layer 0, so here is the code:
(defun c:cld ()
;define the function
;********************************************************
;Save Current Layer as Variable previouslayer
(setq previouslayer (getvar "clayer"))
;**********************************************************
;Start of Command Function
(command "-Layer" "Set" "DIMENSIONS" ""
"Dimlinear" pause pause pause
"-Layer" "Set" previouslayer ""
) ;End Command
;End of Command Function
;*********************************************************
(princ)
;finish cleanly
) ;end of defun


From contributor A:
Okay so the Autolisps are more powerful. I have never taken the time to learn them but now I will. Can you suggest a book? Like Autolisps for dummies or something? To the original questioner: I do not believe there is a way you can repeat the command. I just hit the button over again.

Would you like to add information to this article?
Interested in writing or submitting an article?
Have a question about this article?


Have you reviewed the related Knowledge Base areas below?
  • KnowledgeBase: Knowledge Base

  • KnowledgeBase: Computerization

  • KnowledgeBase: Computerization: CAD Computer Related Design


    Would you like to add information to this article? ... Click Here

    If you have a question regarding a Knowledge Base article, your best chance at uncovering an answer is to search the entire Knowledge Base for related articles or to post your question at the appropriate WOODWEB Forum. Before posting your message, be sure to
    review our Forum Guidelines.

    Questions entered in the Knowledge Base Article comment form will not generate responses! A list of WOODWEB Forums can be found at WOODWEB's Site Map.

    When you post your question at the Forum, be sure to include references to the Knowledge Base article that inspired your question. The more information you provide with your question, the better your chances are of receiving responses.

    Return to beginning of article.



    Refer a Friend || Read This Important Information || Site Map || Privacy Policy || Site User Agreement

    Letters, questions or comments? E-Mail us and let us know what you think. Be sure to review our Frequently Asked Questions page.

    Contact us to discuss advertising or to report problems with this site.

    To report a problem, send an e-mail to our Webmaster

    Copyright © 1996-2016 - WOODWEB ® Inc.
    All rights reserved. No part of this publication may be reproduced in any manner without permission of the Editor.
    Review WOODWEB's Copyright Policy.

    The editors, writers, and staff at WOODWEB try to promote safe practices. What is safe for one woodworker under certain conditions may not be safe for others in different circumstances. Readers should undertake the use of materials and methods discussed at WOODWEB after considerate evaluation, and at their own risk.

    WOODWEB, Inc.
    335 Bedell Road
    Montrose, PA 18801

    Contact WOODWEB











  • WOODWEB - the leading resource for professional woodworkers


      Home » Knowledge Base » Knowledge Base Article