Author Topic: Custom dimension style lisp needed  (Read 206 times)

0 Members and 1 Guest are viewing this topic.

notredave

  • Newt
  • Posts: 94
Custom dimension style lisp needed
« on: June 12, 2019, 09:32:32 AM »
All,

Good morning. I posted this request here also.

https://www.cadtutor.net/forum/topic/67950-customized-dimension-style/

I am trying to find a lisp that I can modify to set my dimension style without manually doing it. This is what I have but gives me an error, misplaced dot on input. If someone can help me, it would be greatly appreciated. I might add some more SETVAR's after it works.

Thank you,
David

( (lambda ( / _dimstyle-setup )
   (defun _dimstyle-setup ( / )
     (mapcar 'eval
             '(
               (SETVAR "DIMADEC" 0) (SETVAR "DIMALT" 0) (SETVAR "DIMALTD" 2) (SETVAR "DIMASZ" 0.1875)
               (SETVAR "DIMALTF" 25.4) (SETVAR "DIMALTRND" 0.0) (SETVAR "DIMALTTD" 2) (SETVAR "DIMCLRD" 1)
           (SETVAR "DIMTXSTY" ROMANS) (SETVAR "DIMGAP" 0.09375) (SETVAR "DIMELTEX1" BYBLOCK)
               (SETVAR "DIMLWD" BYLAYER) (SETVAR "DIMEXE" .06250) (SETVAR "DMLUNIT" ARCHITECTURAL)
               (SETVAR "DIMCLRT" 2) (SETVAR "DIMTXSTY" ROMANS) (SETVAR "DIMDEC" .06250)
               (SETVAR "DIMJUST" CENTERED) (SETVAR "DIMTAD" ABOVE) (SETVAR "DIMTOH" ON)
               ;
               ; ...<snip> All your variables.
               ;
               (SETVAR "DIMTXT" 0.09375) (SETVAR "DIMTZIN" 0) (SETVAR "DIMUPT" 0)
               (SETVAR "DIMZIN")
               )
             )
     )

   (if (tblsearch "DIMSTYLE" "<STANDARD1>")
     (progn
       ;; if the dimstyle exists
       ;; make sure its setup properly
       (_dimstyle-setup)
       ;; set it current
       (command "-dimstyle" "r" "<STANDARD1>")
       )
     (progn
       ;; otherwise
       ;; set it up properly
       (_dimstyle-setup)
       ;; save it.
       (command "-dimstyle" "s" "<STANDARD1>")
       )
     )
   )
)

roy_043

  • Water Moccasin
  • Posts: 1700
  • BricsCAD 18
Re: Custom dimension style lisp needed
« Reply #1 on: June 12, 2019, 09:48:44 AM »
.06250 etc. should be 0.06250

tombu

  • Newt
  • Posts: 150
  • ByLayer=>Not0
Re: Custom dimension style lisp needed
« Reply #2 on: June 12, 2019, 10:04:34 AM »
As modifying dimension related system variables affects the current dimension style I recommend adding all the dimension styles you need to a template drawing and simply importing them into your drawing with lisp.  Using Lee Mac's Steal from Drawing http://lee-mac.com/steal.html with a click I import all the dimension styles from "Templates.dwt".
Code: [Select]
^C^C^P(or C:Steal (load "StealV1-8.lsp"))(Steal (strcat (vl-filename-directory (getenv "QnewTemplate")) (chr 92) "AutoCAD Template" (chr 92) "Templates.dwt") '(("Dimension Styles"("*"))))) .regen
Replacing the * with a list of dimension styles would bring in only the ones in the list.

No new code needed.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

notredave

  • Newt
  • Posts: 94
Re: Custom dimension style lisp needed
« Reply #3 on: June 12, 2019, 11:37:10 AM »
Thank you roy_043 and tombu for responding. After tweaking it some more, I am now receiving error: too few arguments. Also, if this gets fixed, where can I put C:std1 to execute lisp after loaded or will it automatically load when lisp is loaded? Below is updated code giving me the error.

Thank you,
David

( (lambda ( / _dimstyle-setup )
   (defun _dimstyle-setup ( / )
     (mapcar 'eval
             '(
               (SETVAR "DIMADEC" 0) (SETVAR "DIMALT" 0) (SETVAR "DIMALTD" 2) (SETVAR "DIMASZ" 0.1875)
               (SETVAR "DIMALTF" 25.4) (SETVAR "DIMALTRND" 0.0) (SETVAR "DIMALTTD" 2) (SETVAR "DIMCLRD" 1)
          (SETVAR "DIMTXSTY" "ROMANS") (SETVAR "DIMGAP" 0.09375) (SETVAR "DIMLTEX1" "BYBLOCK")
               (SETVAR "DIMLWD" -1) (SETVAR "DIMEXE" 0.06250) (SETVAR "DIMLUNIT" 4)
               (SETVAR "DIMCLRT" 2) (SETVAR "DIMTXSTY" "ROMANS") (SETVAR "DIMDEC" 4)
               (SETVAR "DIMJUST" 0) (SETVAR "DIMTAD" 1) (SETVAR "DIMTOH" 0)
               ;
               ; ...<snip> All your variables.
               ;
               (SETVAR "DIMTXT" 0.09375) (SETVAR "DIMTZIN" 0) (SETVAR "DIMUPT" 0)
               (SETVAR "DIMZIN")
               )
             )
     )

   (if (tblsearch "DIMSTYLE" "<STANDARD1>")
     (progn
       ;; if the dimstyle exists
       ;; make sure its setup properly
       (_dimstyle-setup)
       ;; set it current
       (command "-dimstyle" "r" "<STANDARD1>")
       )
     (progn
       ;; otherwise
       ;; set it up properly
       (_dimstyle-setup)
       ;; save it.
       (command "-dimstyle" "s" "<STANDARD1>")
       )
     )
   )
)

roy_043

  • Water Moccasin
  • Posts: 1700
  • BricsCAD 18
Re: Custom dimension style lisp needed
« Reply #4 on: June 12, 2019, 12:52:23 PM »
The code should start automatically when the file is loaded. Please read the comments. BTW: can you please use code tags when posting code?
Code - Auto/Visual Lisp: [Select]
  1. (
  2.   (lambda ( / _dimstyle-setup )
  3.     ; Note: Unless ALL dim variables are listed the result of the code will be inconsistent.
  4.     (defun _dimstyle-setup ( / )
  5.       (mapcar
  6.         'eval
  7.         '(
  8.           (SETVAR "DIMADEC" 0) (SETVAR "DIMALT" 0) (SETVAR "DIMALTD" 2) (SETVAR "DIMASZ" 0.1875)
  9.           (SETVAR "DIMALTF" 25.4) (SETVAR "DIMALTRND" 0.0) (SETVAR "DIMALTTD" 2) (SETVAR "DIMCLRD" 1)
  10.           (SETVAR "DIMTXSTY" "ROMANS") (SETVAR "DIMGAP" 0.09375) (SETVAR "DIMLTEX1" "BYBLOCK") ; Note: textstyle "ROMANS" must exist.
  11.           (SETVAR "DIMLWD" -1) (SETVAR "DIMEXE" 0.06250) (SETVAR "DIMLUNIT" 4)
  12.           (SETVAR "DIMCLRT" 2) (SETVAR "DIMTXSTY" "ROMANS") (SETVAR "DIMDEC" 4)
  13.           (SETVAR "DIMJUST" 0) (SETVAR "DIMTAD" 1) (SETVAR "DIMTOH" 0)
  14.           (SETVAR "DIMTXT" 0.09375) (SETVAR "DIMTZIN" 0) (SETVAR "DIMUPT" 0)
  15.           (SETVAR "DIMZIN" 3) ; Added an argument.
  16.         )
  17.       )
  18.     )
  19.     (_dimstyle-setup)
  20.     ; Note: You cannot use "<" and ">" in the name.
  21.     (command "_.-dimstyle" "_save" "STANDARD1")       ; Using restore if STANDARD1 already exists does not make sense.
  22.     (if (/= 0 (getvar "cmdactive")) (command "_yes")) ; To handle overwrite prompt.
  23.   )
  24. )
« Last Edit: June 12, 2019, 01:14:46 PM by roy_043 »

notredave

  • Newt
  • Posts: 94
Re: Custom dimension style lisp needed
« Reply #5 on: June 12, 2019, 01:18:59 PM »
roy_043,

Thank you so much! It is working. I really do appreciate it.