DimStyle Overrides with LISP

Discussion in 'AutoCAD' started by John Avitt, Jan 27, 2005.

  1. John Avitt

    John Avitt Guest

    How can I access dimension style overrides with AutoLISP?

    For instance, take a drawing with no overrides in effect. When I use
    (setvar) to set one of the dimstyle system variables, it creates an override
    on the current dimstyle instead of modifying the original dimension style. I
    want to modify the original dimstyle, not create an override.

    Thank you.

    John
     
    John Avitt, Jan 27, 2005
    #1
  2. John Avitt

    John Avitt Guest

    I should have mentioned, I want it done without using the (command)
    function.

    Thank you.

    John
     
    John Avitt, Jan 27, 2005
    #2
  3. You can make your changes and then Save the combination to the Style Name
    you want to "fix." Like this Screen Menu pick routine I use (put your
    preferred values in, plus any other variables you need that we don't bother
    with, like tolerances, etc.):

    [DimStyleStandardize]DIMADEC 4 DIMASZ 1/16 +
    DIMATFIT 3 DIMAUNIT 1 DIMCEN 1/16 +
    DIMCLRD 256 DIMCLRE 1 DIMCLRT 256 +
    DIMDLI 1/4 DIMEXE 1/16 DIMGAP 1/32 +
    DIMLUNIT 4 DIMRND 1/16 DIMSCALE +
    (getvar "<whatever-you-use>") DIMSE1 0 DIMSE2 0 +
    DIMTAD 0 DIMTFAC 7/8 DIMTIH 0 DIMTIX 0 +
    DIMTOFL 0 DIMTOH 0 DIMTXSTY ROMANS +
    DIMTXT 3/32 DIMZIN 3 +
    -DIMSTYLE S <your-dimstyle-name> Y

    That last line is the one you want most.
     
    Kent Cooper, AIA, Jan 27, 2005
    #3
  4. John Avitt

    John Avitt Guest

    Kent,

    Thank you for your post. This works good from a menu item, but I want to use
    strictly AutoLISP, and without using the (command) function.

    I want to use AutoLISP to change the current dimstyle. Using the (setvar)
    function on a dimension system variable only creates an override against the
    current dimstyle. It does not change the dimstyle.

    Thank you.

    John


     
    John Avitt, Jan 27, 2005
    #4
  5. John Avitt

    T.Willey Guest

    See if this works for you. Make all your changes to the dim variables you want. Then do:

    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (setq DimCol (vla-get-DimStyles ActDoc))
    (setq DimSty (vla-Item DimCol <your style name here>))
    (vla-CopyFrom DimSty ActDoc)

    Worked on a quick test here, but only had one dim style in the drawing, but it updated witht he overrides.
    Tim
     
    T.Willey, Jan 27, 2005
    #5
  6. I don't know, but I wonder (for those who know the more exotic ways of doing
    things than I do) -- is there anything equivalent to an "association list"
    for things like the variables in Dimstyles, such that you could use
    something similar to (entmod) & (entupd) to assign new values? That general
    kind of approach (if available) might be a way to do the equivalent of
    (setvar "DIMwhatever" <value>) in a way that would change the dimstyle, in
    Lisp without using (command).

    [But I do confess to being just a little curious as to why it needs to be
    "strictly AutoLISP, and without using the (command) function." Does
    "strictly AutoLISP" mean you don't want VL-whatever or ActiveX, either?]

    Converting my thing (below) into Lisp would require (command) to invoke the
    DIMSTYLE part. Even putting my thing into a Script and using AutoCAD to
    call that would take (command) to invoke Script....
    --
    Kent Cooper, AIA


     
    Kent Cooper, AIA, Jan 27, 2005
    #6
  7. John Avitt

    GaryDF Guest

    This is how I do it (by way of dialog box)
    here is the guts of the routine:


    (DIMSETUP_DIM0) ;;sets tick dimstyle

    Gary


    ;;from my dimstyle setup routine:
    (defun SET_DIMNAME ()
    (cond
    ((= ARCH#UNIT "Ci")
    (progn
    (setvar "dimunit" 2)
    (setvar "dimaunit" 4)
    (setvar "dimdec" 2)
    (setq DIMNAME (rtos (getvar "dimscale") 2 0))
    )
    )
    ((= ARCH#UNIT "Mm")
    (METRIC_DIMNAME)
    )
    ((= ARCH#UNIT "Cm")
    (METRIC_DIMNAME)
    )
    ((= ARCH#UNIT "Ar")
    (progn
    (setvar "dimunit" 6)
    (setvar "dimaunit" 1)
    (setvar "dimdec" 4) ;1/16"
    (setq DIMNAME (rtos (getvar "dimscale") 2 0))
    )
    )
    ((= ARCH#UNIT "Me")
    (METRIC_DIMNAME)
    )
    ((= ARCH#UNIT "En")
    (progn
    (setvar "dimunit" 6)
    (setvar "dimaunit" 1)
    (setvar "dimdec" 4) ;1/16"
    (setq DIMNAME (rtos (getvar "dimscale") 2 0))
    )
    )
    )
    (princ)
    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun METRIC_DIMNAME ()
    (setvar "dimunit" 2)
    (setvar "dimaunit" 1)
    (setvar "dimdec" 1)
    (setvar "dimadec" 4)
    (setq DIMNAME (rtos (getvar "dimscale") 2 0))
    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM0 (/ name0)
    (setvar "cmdecho" 0)
    (ARCH_DIM)
    (ARCH:BLKNAM "ARR" (strcat ARCH#CUSF "DIMS/"))
    (COMMAND "INSERT"
    (strcat "_CLOSED=" ARCH#CUSF "DIMS/" "ARR")
    ^c
    )
    ;;(setvar "DIMBLK" "ARR")
    (setvar "DIMBLK1" "_CLOSED")
    (setvar "DIMBLK2" "_CLOSED")
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first. *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name0 (strcat "ARWW-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name0 (strcat "ARWW-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name0 (strcat "ARWW-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name0 (strcat "ARWW-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name0 (strcat "ARWW-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name0 (strcat "ARWW-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name0))) name0)(command "dimstyle"
    "S" name0))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name0))) name0)(command "dimstyle"
    "R" name0))
    )
    ;;(princ (strcat "\n* New Dimstyle \"" name0 "\" has been completed *"))
    (princ)
    )
    ;;arww

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM1 (/ name1)
    (setvar "cmdecho" 0)
    (ARCH_DIM)
    (ARCH:BLKNAM "TICK" (strcat ARCH#CUSF "DIMS/"))
    (COMMAND "INSERT"
    (strcat "_ARCHTICK=" ARCH#CUSF "DIMS/" "TICK")
    ^c
    )
    (setvar "DIMBLK1" "_ARCHTICK")
    (setvar "DIMBLK2" "_ARCHTICK")
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name1 (strcat "TICK-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name1 (strcat "TICK-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name1 (strcat "TICK-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name1 (strcat "TICK-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name1 (strcat "TICK-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name1 (strcat "TICK-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name1))) name1)(command "dimstyle"
    "S" name1))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name1))) name1)(command "dimstyle"
    "R" name1))
    )
    ;;(if (and name1)(setq current_dimension_style name1))
    ;;(princ (strcat "\n* New Dimstyle \"" name1 "\" has been completed *"))
    (princ)
    )
    ;;tick

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM2 (/ name2)
    (setvar "cmdecho" 0)
    (ARCH_DIM)
    (ARCH:BLKNAM "DOTT" (strcat ARCH#CUSF "DIMS/"))
    (command "insert" (strcat ARCH#CUSF "DIMS/" "DOTT") ^c)
    (setvar "DIMBLK1" "DOTT")
    (setvar "DIMBLK2" "DOTT")
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name2 (strcat "DOT-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name2 (strcat "DOT-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name2 (strcat "DOT-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name2 (strcat "DOT-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name2 (strcat "DOT-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name2 (strcat "DOT-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name2))) name2)(command "dimstyle"
    "S" name2))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name2))) name2)(command "dimstyle"
    "R" name2))
    )
    ;;(princ (strcat "\n* New Dimstyle \"" name2 "\" has been completed *"))
    (princ)
    )
    ;;dot

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM3 (/ name3)
    (setvar "cmdecho" 0)
    (ARCH_DIM)
    (ARCH:BLKNAM "TICK" (strcat ARCH#CUSF "DIMS/"))
    (COMMAND "INSERT"
    (strcat "_ARCHTICK=" ARCH#CUSF "DIMS/" "TICK")
    ^c
    )
    (ARCH:BLKNAM "DOTT" (strcat ARCH#CUSF "DIMS/"))
    (command "insert" (strcat ARCH#CUSF "DIMS/" "DOTT") ^c)
    (setvar "DIMBLK2" "_ARCHTICK")
    (setvar "DIMBLK1" "DOTT")
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name3 (strcat "DOTTICK-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name3 (strcat "DOTTICK-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name3 (strcat "DOTTICK-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name3 (strcat "DOTTICK-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name3 (strcat "DOTTICK-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name3 (strcat "DOTTICK-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name3))) name3)(command "dimstyle"
    "S" name3))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name3))) name3)(command "dimstyle"
    "R" name3))
    )
    ;;(princ (strcat "\n* New Dimstyle \"" name3 "\" has been completed *"))
    (princ)
    )
    ;;dottick

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM4 (/ name4)
    (setvar "cmdecho" 0)
    (ARCH_DIM)
    (ARCH:BLKNAM "TICK" (strcat ARCH#CUSF "DIMS/"))
    (COMMAND "INSERT"
    (strcat "_ARCHTICK=" ARCH#CUSF "DIMS/" "TICK")
    ^c
    )
    (ARCH:BLKNAM "DOTT" (strcat ARCH#CUSF "DIMS/"))
    (command "insert" (strcat ARCH#CUSF "DIMS/" "DOTT") ^c)
    (setvar "DIMBLK1" "_ARCHTICK")
    (setvar "DIMBLK2" "DOTT")
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name4 (strcat "TICKDOT-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name4 (strcat "TICKDOT-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name4 (strcat "TICKDOT-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name4 (strcat "TICKDOT-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name4 (strcat "TICKDOT-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name4 (strcat "TICKDOT-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name4))) name4)(command "dimstyle"
    "S" name4))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name4))) name4)(command "dimstyle"
    "R" name4))
    )
    ;;(princ (strcat "\n* New Dimstyle \"" name4 "\" has been completed *"))
    (princ)
    )
    ;;tickdot

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM5 (/ name5)
    (setvar "cmdecho" 0)
    (ARCH_DIM)
    (setvar "DIMBLK1" "_NONE") ;First arrow block name
    (setvar "DIMBLK2" "_NONE") ;Second arrow block name
    (setvar "DIMSD1" 1) ;Suppress the first dimension line
    (setvar "DIMSD2" 1) ;Suppress the second dimension line
    (setvar "DIMSE1" 1) ;Suppress the first extension line
    (setvar "DIMSE2" 1) ;Suppress the second extension line
    (setvar "DIMZIN" 0) ;Zero suppression
    (setvar "DIMTZIN" 0) ;Tolerance zero suppression
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name5 (strcat "LEASE-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name5 (strcat "LEASE-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name5 (strcat "LEASE-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name5 (strcat "LEASE-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name5 (strcat "LEASE-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name5 (strcat "LEASE-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name5))) name5)(command "dimstyle"
    "S" name5))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name5))) name5)(command "dimstyle"
    "R" name5))
    )
    ;;(princ (strcat "\n* New Dimstyle \"" name5 "\" has been completed *"))
    (princ)
    )
    ;;lease

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM6 (/ name6)
    (setvar "cmdecho" 0)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.2)
    )
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" (* 25.4 0.2))
    )
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" (* 2.54 0.2))
    )
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.2)
    )
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" (* 0.0254 0.2))
    )
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.2)
    )
    )
    (cond
    ((= ARCH#CLAY "Off")
    (setvar "DIMCLRD" 1) ;;256
    )
    )
    (cond
    ((= (atoi (substr (getvar "acadver") 1 2)) 14)
    (setvar "DIMBLK1" ".")
    (setvar "DIMBLK2" ".")
    )
    )
    (cond
    ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (setvar "DIMLDRBLK" ".")
    )
    )
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name6 (strcat "ALDR-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name6 (strcat "ALDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name6 (strcat "ALDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name6 (strcat "ALDR-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name6 (strcat "ALDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name6 (strcat "ALDR-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name6))) name6)(command "dimstyle"
    "S" name6))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name6))) name6)(command "dimstyle"
    "R" name6))
    )
    (princ)
    )
    ;;aleader

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM7 (/ name7)
    (setvar "cmdecho" 0)
    (if (= ARCH#UNIT "0")
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.0625)
    )
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" (* 25.4 0.0625))
    )
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" (* 2.54 0.0625))
    )
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.0625)
    )
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" (* 0.0254 0.0625))
    )
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.0625)
    )
    (cond
    ((= ARCH#CLAY "Off")
    (setvar "DIMCLRD" 1) ;;256
    (princ)
    )
    )
    (cond ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (setvar "DIMLDRBLK" "_DOT")
    )
    )
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name7 (strcat "DLDR-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name7 (strcat "DLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name7 (strcat "DLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name7 (strcat "DLDR-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name7 (strcat "DLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name7 (strcat "DLDR-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name7))) name7)(command "dimstyle"
    "S" name7))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name7))) name7)(command "dimstyle"
    "R" name7))
    )
    (princ)
    )
    ;;dleader

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM8 (/ name8)
    (setvar "cmdecho" 0)
    (command "INSERT"
    (strcat "_INTEGRAL=" ARCH#CUSF "DIMS/" "ARCH_XLDR")
    ^c
    )
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" (* 25.4 0.125))
    )
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" (* 2.54 0.125))
    )
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" (* 0.0254 0.125))
    )
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.125)
    )
    (cond
    ((= ARCH#CLAY "Off")
    (setvar "DIMCLRD" 256)
    (princ)
    )
    )
    (cond ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (setvar "DIMLDRBLK" "_INTEGRAL")
    )
    )
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name8 (strcat "XLDR-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name8 (strcat "XLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name8 (strcat "XLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name8 (strcat "XLDR-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name8 (strcat "XLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name8 (strcat "XLDR-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name8))) name8)(command "dimstyle"
    "S" name8))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name8))) name8)(command "dimstyle"
    "R" name8))
    )
    (princ)
    )
    ;;xleader

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM9 (/ name9)
    (setvar "cmdecho" 0)
    (command "INSERT"
    (strcat "_OPEN90=" ARCH#CUSF "DIMS/" "ARCH_LLDR")
    ^c
    )
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" (* 25.4 0.125))
    )
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" (* 2.54 0.125))
    )
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" (* 0.0254 0.125))
    )
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.125)
    )
    (cond
    ((= ARCH#CLAY "Off")
    (setvar "DIMCLRD" 256)
    (princ)
    )
    )
    (cond ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (setvar "DIMLDRBLK" "_OPEN90")
    )
    )
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name9 (strcat "LLDR-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name9 (strcat "LLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name9 (strcat "LLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name9 (strcat "LLEADER-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name9 (strcat "LLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name9 (strcat "LLEADER-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name9))) name9)(command "dimstyle"
    "S" name9))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name9))) name9)(command "dimstyle"
    "R" name9))
    )
    (princ)
    )
    ;;lleader

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM10 (/ name10)
    (setvar "cmdecho" 0)
    (command "INSERT"
    (strcat "_OPEN30=" ARCH#CUSF "DIMS/" "ARCH_VLDR")
    ^c
    )
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" (* 25.4 0.125))
    )
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" (* 2.54 0.125))
    )
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" (* 0.0254 0.125))
    )
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.125)
    )
    (cond
    ((= ARCH#CLAY "Off")
    (setvar "DIMCLRD" 256)
    (princ)
    )
    )
    (cond ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (setvar "DIMLDRBLK" "_OPEN30")
    )
    )
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name10 (strcat "VLDR-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name10 (strcat "VLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name10 (strcat "VLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name10 (strcat "VLDR-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name10 (strcat "VLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name10 (strcat "VLDR-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name10))) name10)(command "dimstyle"
    "S" name10))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name10))) name10)(command "dimstyle"
    "R" name10))
    )
    (princ)
    )
    ;;vleader

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun DIMSETUP_DIM11 (/ name11)
    (setvar "cmdecho" 0)
    (command "INSERT"
    (strcat "_OPEN30=" ARCH#CUSF "DIMS/" "ARCH_SLDR")
    ^c
    )
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" (* 25.4 0.125))
    )
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" (* 2.54 0.125))
    )
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.125)
    )
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" (* 0.0254 0.125))
    )
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.125)
    )
    (cond
    ((= ARCH#CLAY "Off")
    (setvar "DIMCLRD" 256)
    (princ)
    )
    )
    (cond ((>= (atoi (substr (getvar "acadver") 1 2)) 15)
    (setvar "DIMLDRBLK" "_OPEN30")
    )
    )
    (SET_DIMNAME)
    (progn
    (if (= ARCH#UNIT nil)
    (Prompt "\n* Run Drawing File SETUP first *")
    )
    (if (= ARCH#UNIT "Ci")
    (setq name10 (strcat "SLDR-D-" DIMNAME))
    )
    (if (= ARCH#UNIT "Mm")
    (setq name10 (strcat "SLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Cm")
    (setq name10 (strcat "SLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "Ar")
    (setq name10 (strcat "SLDR-" DIMNAME))
    )
    (if (= ARCH#UNIT "Me")
    (setq name10 (strcat "SLDR-M-" DIMNAME))
    )
    (if (= ARCH#UNIT "En")
    (setq name10 (strcat "SLDR-" DIMNAME))
    )
    )
    (cond
    ((/= (cdr (assoc 2 (tblsearch "dimstyle" name11))) name11)(command "dimstyle"
    "S" name11))
    ((= (cdr (assoc 2 (tblsearch "dimstyle" name11))) name11)(command "dimstyle"
    "R" name11))
    )
    (princ)
    )
    ;;sleader

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;; Main Dimension Setvars
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH_DIM () ;ARCHITETTURA
    (setvar "cmdecho" 0)
    (ARCH:SET-DIMS)
    ;;(command "insert" (strcat ARCH#CUSF "DIMS/" "TICK") ^c) ;not needed
    ;;tick block inserted
    ;;(command "insert" (strcat ARCH#CUSF "DIMS/" "DOTT") ^c) ;not needed
    ;;dott block inserted

    (setvar "DIMALT" 0) ;Alternate units selected
    (setvar "DIMALTD" 2) ;Alternate unit decimal places
    (setvar "DIMALTF" 25.40000000) ;Alternate unit scale factor
    (setvar "DIMALTTD" 2) ;Alternate tolerance decimal places
    (setvar "DIMALTTZ" 3) ;Alternate tolerance zero suppression
    (setvar "DIMALTU" 4) ;Alternate units
    (setvar "DIMALTZ" 3) ;Alternate unit zero suppression
    ;;(setvar "DIMASO" 1) ;Create associative dimensions
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;arrow size
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMASZ" 0.09375)
    ) ;Arrow size
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMASZ" 2.5)
    ) ;Arrow size
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMASZ" 0.25)
    ) ;Arrow size
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMASZ" 0.09375)
    ) ;Arrow size
    (if (= ARCH#UNIT "Me")
    (setvar "DIMASZ" 0.0025)
    ) ;Arrow size
    (if (= ARCH#UNIT "En")
    (setvar "DIMASZ" 0.09375)
    ) ;Arrow size
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;center mark size
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMCEN" 0.09375)
    ) ;Center mark size
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMCEN" 2.5)
    ) ;Center mark size
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMCEN" 0.25)
    ) ;Center mark size
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMCEN" 0.09375)
    ) ;Center mark size
    (if (= ARCH#UNIT "Me")
    (setvar "DIMCEN" 0.0025)
    ) ;Center mark size
    (if (= ARCH#UNIT "En")
    (setvar "DIMCEN" 0.09375)
    ) ;Center mark size

    ;;dimension line and leader color
    (setvar "DIMCLRD" 30) ;Dimension line and leader color

    ;;extension line color
    (setvar "DIMCLRE" 30) ;Extension line color

    ;;dimension text color
    (setvar "DIMCLRT" 2) ;Dimension text color

    (setvar "DIMDLE" 0.09375) ;Dimension line extension

    ;;dimension line spacing
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMDLI" 0.25)
    ) ;Dimension line spacing
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMDLI" 10.0)
    ) ;Dimension line spacing
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMDLI" 1.0)
    ) ;Dimension line spacing
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMDLI" 0.25)
    ) ;Dimension line spacing
    (if (= ARCH#UNIT "Me")
    (setvar "DIMDLI" 0.01)
    ) ;Dimension line spacing
    (if (= ARCH#UNIT "En")
    (setvar "DIMDLI" 0.25)
    ) ;Dimension line spacing

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;extension above dimension line
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMEXE" 0.0625)
    ) ;Extension above dimension line
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMEXE" 1.0)
    ) ;Extension above dimension line
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMEXE" 0.1)
    ) ;Extension above dimension line
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMEXE" 0.0625)
    ) ;Extension above dimension line
    (if (= ARCH#UNIT "Me")
    (setvar "DIMEXE" 0.001)
    ) ;Extension above dimension line
    (if (= ARCH#UNIT "En")
    (setvar "DIMEXE" 0.0625)
    ) ;Extension above dimension line

    ;;extension line origin offset
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMEXO" 0.0625)
    ) ;Extension line origin offset
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMEXO" 2.0)
    ) ;Extension line origin offset
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMEXO" 0.2)
    ) ;Extension line origin offset
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMEXO" 0.0625)
    ) ;Extension line origin offset
    (if (= ARCH#UNIT "Me")
    (setvar "DIMEXO" 0.002)
    ) ;Extension line origin offset
    (if (= ARCH#UNIT "En")
    (setvar "DIMEXO" 0.0625)
    ) ;Extension line origin offset
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;

    (setvar "DIMFIT" 5) ;Fit text

    ;;gap from dimension line to text
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMGAP" 0.0625)
    ) ;Gap from dimension line to text
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMGAP" 1.0)
    ) ;Gap from dimension line to text
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMGAP" 0.1)
    ) ;Gap from dimension line to text
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMGAP" 0.0625)
    ) ;Gap from dimension line to text
    (if (= ARCH#UNIT "Me")
    (setvar "DIMGAP" 0.001)
    ) ;Gap from dimension line to text
    (if (= ARCH#UNIT "En")
    (setvar "DIMGAP" 0.0625)
    ) ;Gap from dimension line to text

    (setvar "DIMJUST" 0) ;Justification of text on dimension line
    (setvar "DIMLFAC" 1.00000000) ;Linear unit scale factor
    (setvar "DIMLIM" 0) ;Generate dimension limits
    (setvar "DIMRND" 0) ;Rounding value
    (setvar "DIMSAH" 1) ;Separate F_ARROW blocks
    (setvar "DIMSD1" 0) ;Suppress the first dimension line
    (setvar "DIMSD2" 0) ;Suppress the second dimension line
    (setvar "DIMSE1" 0) ;Suppress the first extension line
    (setvar "DIMSE2" 0) ;Suppress the second extension line
    ;;(setvar "DIMSHO" 1) ;DIMSETUP dimensions while dragging
    (setvar "DIMSOXD" 0) ;Suppress outside dimension lines
    (setvar "DIMTAD" 1) ;Place text above the dimension line
    (setvar "DIMTDEC" 7) ;Tolerance decimal places
    (setvar "DIMTFAC" 1.00000000) ;Tolerance text height scaling factor
    (setvar "DIMTIH" 0) ;Text inside extensions is horizontal
    (setvar "DIMTIX" 1) ;Place text inside extensions
    (setvar "DIMTM" 0) ;Minus tolerance
    (setvar "DIMTOFL" 1) ;Force line inside extension lines
    (setvar "DIMTOH" 0) ;Text outside horizontal
    (setvar "DIMTOL" 0) ;Tolerance dimensioning
    (setvar "DIMTOLJ" 1) ;Tolerance vertical justification
    (setvar "DIMTP" 0) ;Plus tolerance
    (setvar "DIMTSZ" 0) ;Tick size
    (setvar "DIMTVP" 0.00000000) ;Text vertical position
    ;;Text style names
    (setvar "DIMTXSTY" ARCH#TXSD) ;Text style

    ;;text heights
    (if (= ARCH#UNIT "Ci")
    (setvar "DIMTXT" 0.09375)
    ) ;Text height
    (if (= ARCH#UNIT "Mm")
    (setvar "DIMTXT" 2.25)
    ) ;Text height
    (if (= ARCH#UNIT "Cm")
    (setvar "DIMTXT" 0.225)
    ) ;Text height
    (if (= ARCH#UNIT "Ar")
    (setvar "DIMTXT" 0.09375)
    ) ;Text height
    (if (= ARCH#UNIT "Me")
    (setvar "DIMTXT" 0.00225)
    ) ;Text height
    (if (= ARCH#UNIT "En")
    (setvar "DIMTXT" 0.09375)
    ) ;Text height

    (setvar "DIMTZIN" 3) ;Tolerance zero suppression
    (setvar "DIMUPT" 0) ;User positioned text
    (setvar "DIMZIN" 3) ;Zero suppression
    (princ)
    )
     
    GaryDF, Jan 27, 2005
    #7
  8. John Avitt

    Adesu Guest

    Hi John, my script may be help you,if you want add others setvar,add at
    setvar group on my code,here my code

    ; cds is stand for create dimension style
    ; Design by Ade Suharna <>
    ; 18 January 2005
    ; Program no.167/01/2005
    ; Edit by Ade Suharna 28/01/2005 1).
    (defun c:cds (/ scl fcal scal dmasz dexo dexo dtxt dgap dclre dclrt
    dsn ao ad obj)
    (vl-load-com)
    (setq scl (getstring "\nENTER SCALE DRAWING: "))
    (setq fcal (atof (substr scl 1 1)))
    (setq scal (atof (substr scl 3 3)))
    (setq scl (cond ((> fcal 1)
    (progn
    (setq dmasz (/ fcal 2.0))
    (setq dexe (/ fcal 2.0))
    (setq dexo (/ fcal 2.0))
    (setq dtxt (/ fcal 2.0))
    (setq dgap fcal)
    (setq dclre 7)
    (setq dclrt 1)))
    ((> scal 1)
    (progn
    (setq dmasz (* scal 2.0))
    (setq dexe (* scal 2.0))
    (setq dexo (* scal 2.0))
    (setq dtxt (* scal 2.0))
    (setq dgap scal)
    (setq dclre 7)
    (setq dclrt 1)))
    ((= scal 1)
    (progn
    (setq dmasz (* scal 1.0))
    (setq dexe (* scal 1.0))
    (setq dexo (* scal 1.0))
    (setq dtxt (* scal 1.0))
    (setq dgap (/ scal 2.0))
    (setq dclre 7)
    (setq dclrt 1)))))
    (setvar "DIMASZ" dmasz) ; 1).
    (setvar "DIMEXE" dexe)
    (setvar "DIMEXO" dexo)
    (setvar "DIMTXT" dtxt)
    (setvar "DIMGAP" dgap)
    (setvar "DIMCLRE" dclre)
    (setvar "DIMCLRT" dclrt)
    (setq dsn (getstring "\nENTER NEW NAME FOR DIMSTYLE: "))
    (setq ao (vlax-get-acad-object))
    (setq ad (vla-get-ActiveDocument ao))
    (vla-setvariable ad "dimscale" dmasz)
    (setq obj (vla-add (vla-get-dimstyles ad) dsn))
    (vla-copyfrom Obj ad)
    (vla-put-activedimstyle ad Obj)
    (princ)
    )
     
    Adesu, Jan 28, 2005
    #8
  9. John Avitt

    John Avitt Guest

    It is just a pet peeve that I have. In my opinion, if you have to use the
    (command) function, then why use AutoLISP at all?

    I sometimes use it anyway, when I can find no other way to do what I need.
    But I try to avoid it when possible. I still think there must be a way to
    access the overrides with AutoLISP, if I can just figure it out. I agree
    that there must be an association list somewhere, but I have not been able
    to find it.

    Thank you.

    John


     
    John Avitt, Jan 28, 2005
    #9
  10. John Avitt

    OLD-CADaver Guest

    <<if you have to use the (command) function, then why use AutoLISP at all?>>

    hmmm... Because the lisp routine will make my job considerably faster and easier. Isn't that the ONLY reason to write ANY program, function, macro or script?
    OTOH, why NOT use it, if it does what you need? There are many things that are just way too difficult to access otherwise.

    <<But I try to avoid it when possible.>>

    Why? Other than knee-jerk OCD responses, what are the COMPELLING reasons for avoiding (command??
     
    OLD-CADaver, Jan 28, 2005
    #10
  11. While I'm not debating the issues of how easy/quick
    the command function is, sometimes it is really nice to
    have a better understanding of what is going on behind
    the scenes. The command function doesn't exactly do
    that. The only other reason I can think of to avoid the
    command function is when dealing with reactor callbacks.
     
    Jason Piercey, Jan 28, 2005
    #11
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.