Dimensions on layer 'Dimension'

Discussion in 'AutoCAD' started by Kiwi Russ, Feb 18, 2005.

  1. Kiwi Russ

    Kiwi Russ Guest

    Hi
    just can't this one out -must be a simple answer!
    I want to use the dimension command that creates dimensions on Layer
    'Dimension'
    Why does it not work, so that it puts it on the right layer and sets it back
    to previous layer.
    thanks
    Russ


    (defun C:test1( / Pt1 OldLay )
    (setq OldLay (getvar "CLAYER"))
    (command "layer" "make" "Dimension" "ltype" "continuous" "" "color" "red"
    "" "")
    (command ".color" "bylayer" )
    (setq pt1 (getpoint "\nSpecify point : "))
    (command "_DIMLINEAR" pt1 " " )
    (setvar "CLAYER" OldLay)
    (princ)
    );defun
     
    Kiwi Russ, Feb 18, 2005
    #1
  2. Kiwi,

    That command requires three arguments....

    ie:

    Command: (command "dimlinear" pause pause pause)

    and in case you are using autocad 2005, you can setup the layers for commands in the toolpalletes... just select the command tab and click on the dimension button, right-click and on properties, select the desired layer.... and other properties as well....

    hth

    I have a program named drawhelp that can do that much easier... a free copy of drawhelp if you want it.

    LE.
     
    Luis Esquivel, Feb 19, 2005
    #2
  3. Kiwi Russ

    Kiwi Russ Guest

    Luis
    yes please I would like to see it.

    Btw I did have 3 arguments but even with pause pause pause it still does
    not work, as far as layering goes ?

    cheers Russ
     
    Kiwi Russ, Feb 19, 2005
    #3
  4. Russ,

    Here is your routine... about drawhelp,send me an email to supportATdraftteam.com, and I will sent the program, it is a reactor base vlx application.

    LE.

    Code:
    (defun C:TEST1	(/ Pt1 OldLay)
    (setq OldLay (getvar "CLAYER"))
    (setvar "cmdecho" 0)
    (command "_.layer"   "_make"	   "Dimension" "_ltype"	   "continuous"
    ""	       "_color"	   "red"       ""	   "")
    (command "_.color" "bylayer")
    (setq pt1 (getpoint "\nSpecify first extension line origin: "))
    (setq pt2 (getpoint pt1 "\nSpecify second extension line origin: "))
    (command "_.DIMLINEAR" pt1 pt2 pause)
    (setvar "CLAYER" OldLay)
    (setvar "cmdecho" 1)
    (princ))
    
     
    Luis Esquivel, Feb 19, 2005
    #4
  5. Kiwi Russ

    Tom Smith Guest

    FWIW, another take on the same thing. I have a utility function for placing dimensions:

    (defun placedim (dimstyle layer dimcommand / *error*)
    (init-error '("cmdecho" "clayer"))
    (setcurrentlayer layer)
    (setdimstyle dimstyle)
    (setvar "cmdecho" 1)
    (command dimcommand)
    (while (= 1 (logand (getvar "cmdactive") 1))
    (command pause))
    (*error* nil))

    This uses the cmdactive trick to keep running a command until complete, and depends on cmdecho to supply prompts to the user.

    I'm calling several other utility functions:

    (init-error <varlist>) begins an undo group and defines an (*error* <message>) function, declared local here.

    (*error* <message>) restores variable settings from <varlist> above, ends the undo group, and issues a mesage if any. This can handle either a normal clean exit, or the user cancelling the command.

    (setcurrentlayer <layer>) Imports the standard layer table if <layer> isn't present, thaws it if frozen, and sets it current.

    (setdimstyle <dimstyle>) does the equivalent for <dimstyle>.

    As initially written, the last two simply set the layer or style current, and 95% of the time this was good enough, since our files are very consistent. Eventually, though, I upgraded them to handle the odd cases where those table items weren't present. By handling chores like layer-setting with a utility function, rather than lisp-by-lisp, I could add this feature to any routines which call it, by editing only the library utility.

    In application, I can call the placedim function from a button with a macro like:

    ^C^C(placedim "dim" "dimension" "dimlinear");

    Which makes it possible to duplicate the standard dimensioning toolbar buttons, but with our dimstyles and layers being enforced. I could also have variant buttons, for instance to place a linear dimension with a different dimstyle on a different layer.
     
    Tom Smith, Feb 20, 2005
    #5
  6. Kiwi Russ

    Jürg Menzi Guest

    Hi Russell

    Try this one:
    Code:
    (defun C:Test1 ( / Pt1 OldCmd OldLay)
    (setq OldCmd (getvar "CMDECHO")
    OldLay (getvar "CLAYER")
    )
    (setvar "CMDECHO" 0)
    (command "_.LAYER" "_MA" "Dimension" "_LT" "Continuous" "" "_CO" "_Red" "" ""
    "_.COLOR" "_ByLayer"
    )
    (if (setq pt1 (getpoint "\nSpecify point: "))
    (progn
    (command "_DIMLINEAR")
    (setvar "CMDECHO" 1)
    (command pt1)
    (while (> (getvar "CMDACTIVE") 0)
    (command pause)
    )
    )
    )
    (setvar "CMDECHO" OldCmd)
    (setvar "CLAYER" OldLay)
    (princ)
    )
    
    Cheers
     
    Jürg Menzi, Feb 21, 2005
    #6
  7. Kiwi Russ

    mission Guest

    mission, Feb 21, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.