Author Topic: dimension lisp works in 2000 but not in 2004  (Read 6124 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
dimension lisp works in 2000 but not in 2004
« on: September 24, 2004, 05:20:53 PM »
I have a bunch of dimension routines where you can enter the command, or click on icon tool bar, to draw a dimension or leader w/ notes to a desired scale.  Its working fine in ACAD 2000i but I cannot get it to work in ACAD 2004. :?:

Here are some examples of the lisp.

Code: [Select]

;Sets Text leader to Full scale
(defun c:diml1 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-text"))
 (if(= lyr nil)
 (progn
 (command "layer" "m" "a-anno-text" "c" "r" "" "")))
 (command "clayer" "a-anno-text")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "l1"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/cadmenu/blocks/l1.dwg" ^c)))
  (command "dimstyle" "r" "l1")
  (setvar "cmdecho" oldcmdecho)
  (command "_qleader")
  (princ)
)

;Sets dimension to Full scale
(defun c:dimm1 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-dims"))
 (if(= lyr nil)
 (progn
 (command "layer" "m" "a-anno-dims" "c" "g" "" "")))
 (command "clayer" "a-anno-dims")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "m1"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/cadmenu/blocks/m1.dwg" ^c)))
  (command "dimstyle" "r" "m1")
  (setvar "cmdecho" oldcmdecho)
  (command "dimlinear")
  (princ)
)

;Sets Text leader to 6" scale (half size)
(defun c:diml2 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-text"))
 (if(= lyr nil)
 (progn
 (command "layer" "m" "a-anno-text" "c" "r" "" "")))
 (command "clayer" "a-anno-text")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "l2"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/cadmenu/blocks/l2.dwg" ^c)))
  (command "dimstyle" "r" "l2")
  (setvar "cmdecho" oldcmdecho)
  (command "_qleader")
  (princ)
)

;Sets dimension to 6" scale (half size)
(defun c:dimm2 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-dims"))
 (if(= lyr nil)
 (progn
 (command "layer" "m" "a-anno-dims" "c" "g" "" "")))
 (command "clayer" "a-anno-dims")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "m2"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/cadmenu/blocks/m2.dwg" ^c)))
  (command "dimstyle" "r" "m2")
  (setvar "cmdecho" oldcmdecho)
  (command "dimlinear")
  (princ)
)

;Sets Text leader to 3" scale
(defun c:diml4 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-text"))
 (if(= lyr nil)
 (progn
 (command "layer" "m" "a-anno-text" "c" "r" "" "")))
 (command "clayer" "a-anno-text")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "l4"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/cadmenu/blocks/l4.dwg" ^c)))
  (command "dimstyle" "r" "l4")
  (setvar "cmdecho" oldcmdecho)
  (command "_qleader")
  (princ)
)

;Sets dimension to 3" scale
(defun c:dimm4 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-dims"))
 (if(= lyr nil)
 (progn
 (command "layer" "m" "a-anno-dims" "c" "g" "" "")))
 (command "clayer" "a-anno-dims")
 (princ)
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "m4"))
  (if(= dstl nil)
  (progn
  (command "insert" "c:/cadmenu/blocks/m4.dwg" ^c)))
  (command "dimstyle" "r" "m4")
  (setvar "cmdecho" oldcmdecho)
  (command "dimlinear")
  (princ)
)


any help is appreciated..

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
dimension lisp works in 2000 but not in 2004
« Reply #1 on: September 24, 2004, 07:04:36 PM »
You might want to try this gem that CAB wrote.
http://theswamp.org/phpBB2/viewtopic.php?t=1392


or not ........... !!  :D
I just noticed that you are insterting blocks as well. sorry  :roll:
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
dimension lisp works in 2000 but not in 2004
« Reply #2 on: September 24, 2004, 07:08:12 PM »
Do you get any error messages? Did you step thought each of the "commands" in one of the functions?
TheSwamp.org  (serving the CAD community since 2003)

Anonymous

  • Guest
dimension lisp works in 2000 but not in 2004
« Reply #3 on: September 24, 2004, 07:48:18 PM »
this is the error message that I get in ACAD 2004
Command: diml1
Unknown command "LAYER".  Press F1 for help.
Unknown command "M".  Press F1 for help.
Unknown command "A-ANNO-TEXT".  Press F1 for help.
Unknown command "C".  Press F1 for help.
Unknown command "R".  Press F1 for help.
Unknown command "DIML1".  Press F1 for help.
Unknown command "DIML1".  Press F1 for help.

Cannot set CLAYER to that value.


 Function cancelled
; error: An error has occurred inside the *error* functionAutoCAD variable
setting rejected: "blipmode" nil
*Invalid*

-this is what I get in ACAD 2000:
Command: diml1 _qleader
Specify first leader point, or [Settings] <Settings>:
Specify first leader point, or [Settings] <Settings>:
Specify next point:
Specify next point:
Specify text width <0">:

Enter first line of annotation text <Mtext>:

I installed the lisp the same way as I did in 2000.
I go to options, file, support, and add a path to a folder called cadmenu.
the cadmenu folder,located on my c: drive, contains 4 subfolders (blocks, icons, menu, temp).  then in CAD I do a menuload, browse to the cadmenu/menu and load the .mns file.

danny

  • Guest
dimension lisp works in 2000 but not in 2004
« Reply #4 on: September 24, 2004, 07:51:06 PM »
sorry, the last message is mine, forgot to log in..
I'll check out Cab routine and see if it works for me..

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
dimension lisp works in 2000 but not in 2004
« Reply #5 on: September 24, 2004, 09:07:13 PM »
try this one;
Code: [Select]

(defun c:dimm1 (/ oldcmdecho return)

  (setq oldcmdecho (getvar "cmdecho"))

  (setvar "cmdecho" 0)

 ; search for existing layer

  (if (not (tblsearch "layer" "a-anno-dims"))

 ; if layer doesn't exist then create it
    (command "layer" "m" "a-anno-dims" "c" "g" "" "")

 ; else

 ; if it does then set it current
    (setvar 'clayer "a-anno-dims")

    ) ; if

 ; set units to Architectural
  (setvar 'lunits 4)

 ; search for existing dim style

  (if (not (tblsearch "dimstyle" "m1"))
    (progn

 ; if not found insert a block that contains it

      (command "insert" "c:/m1.dwg" "0,0" "" "" "")

 ; then set it current
      (command "dimstyle" "r" "m1")

      ) ; progn

 ;else

 ; if it does exist then just set it current
    (command "dimstyle" "r" "m1")

    ) ; if

 ; re-set variable

  (setvar "cmdecho" oldcmdecho)

 ; start dimlinear command
(command "_.dimlinear")

)
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
dimension lisp works in 2000 but not in 2004
« Reply #6 on: September 24, 2004, 09:15:47 PM »
Here is your code with comments.
Code: [Select]

(defun c:dimm1 (/ oldcmdecho); localize your variables
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-dims"))
 (if(= lyr nil)
 (progn ; you don't need this since you only have one expression
 (command "layer" "m" "a-anno-dims" "c" "g" "" ""))); <- if ends here
 (command "clayer" "a-anno-dims");<-- don't need this when using "layer" "m"
 (princ)
    ; use lunit variable instead of units command
  (command "units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "m1"))
  (if(= dstl nil)
  (progn ; you don't need this since you only have one expression
    ; I think the problem is not enough arguments
    ; in the "insert" command
  (command "insert" "c:/m1.dwg"))); <- if ends here
  (command "dimstyle" "r" "m1")
  (setvar "cmdecho" oldcmdecho)
  (command "dimlinear")
  (princ)
)
TheSwamp.org  (serving the CAD community since 2003)

danny

  • Guest
dimension lisp works in 2000 but not in 2004
« Reply #7 on: September 24, 2004, 09:31:51 PM »
mark, still doesn't work. i get this error message
Command: dimm1
Unknown command "LAYER".  Press F1 for help.
Unknown command "M".  Press F1 for help.
Unknown command "A-ANNO-DIMS".  Press F1 for help.
Unknown command "C".  Press F1 for help.
Unknown command "G".  Press F1 for help.
Unknown command "DIMM1".  Press F1 for help.
Unknown command "DIMM1".  Press F1 for help.

"m1.dwg": Can't find file in search path:
  C:\Documents and Settings\derek\My Documents\ (current directory)
  C:\DOCUMENTS AND SETTINGS\DEREK\APPLICATION DATA\AUTODESK\AUTODESK
ARCHITECTURAL DESKTOP 2004\R16.0\ENU\SUPPORT\
  C:\PROGRAM FILES\AUTODESK ARCHITECTURAL DESKTOP 2004\SUPPORT\
  C:\PROGRAM FILES\AUTODESK ARCHITECTURAL DESKTOP 2004\FONTS\
  C:\PROGRAM FILES\AUTODESK ARCHITECTURAL DESKTOP 2004\HELP\
  C:\PROGRAM FILES\AUTODESK ARCHITECTURAL DESKTOP 2004\EXPRESS\
  C:\PROGRAM FILES\AUTODESK ARCHITECTURAL DESKTOP 2004\SUPPORT\COLOR\
  C:\DOCUMENTS AND SETTINGS\ALL USERS\APPLICATION DATA\AUTODESK\AUTODESK
ARCHITECTURAL DESKTOP 2004\R16.0\ENU\LAYERS\
  C:\2004CADMENU\MENU\
  C:\2004cadmenu\text\
  C:\2004cadmenu\blocks\
  C:\Program Files\Autodesk Architectural Desktop 2004\
*Invalid*


 Function cancelled
; error: An error has occurred inside the *error* functionAutoCAD variable
setting rejected: "blipmode" nil

I think I have to upload my cadmenu folder so that we can take a look at the intire setup.  How do I upload this folder?

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
dimension lisp works in 2000 but not in 2004
« Reply #8 on: September 24, 2004, 09:41:54 PM »
try changing the path to your setup.

hint:
"m1.dwg": Can't find file in search path:
TheSwamp.org  (serving the CAD community since 2003)

danny

  • Guest
dimension lisp works in 2000 but not in 2004
« Reply #9 on: September 24, 2004, 10:10:32 PM »
"m1.dwg" is located in "C:\2004cadmenu\blocks\"
the error message shows that it searched this folder?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
dimension lisp works in 2000 but not in 2004
« Reply #10 on: September 24, 2004, 10:13:59 PM »
Quote from: danny
mark, still doesn't work. i get this error message
Command: dimm1
Unknown command "LAYER". Press F1 for help


Looks to me like the layer command may have been redefined.
try this.
Code: [Select]
(defun c:diml1 ()
 (setq oldcmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (setq lyr(tblsearch "layer" "a-anno-text"))
 (if(= lyr nil)
 (progn
 (command ".-layer" "m" "a-anno-text" "c" "r" "" "")))
 (command ".clayer" "a-anno-text")
 (princ)
  (command ".units" "4" "" "" "" "" "")
  (setq dstl(tblsearch "dimstyle" "l1"))
  (if(= dstl nil)
  (progn
  (command ".insert" "c:/cadmenu/blocks/l1.dwg" ^c)))
  (command ".dimstyle" "r" "l1")
  (setvar "cmdecho" oldcmdecho)
  (command "_.qleader")
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

danny

  • Guest
dimension lisp works in 2000 but not in 2004
« Reply #11 on: September 24, 2004, 10:28:57 PM »
thanks CAB, that worked..
What does the "." in front of ".layer" do?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
dimension lisp works in 2000 but not in 2004
« Reply #12 on: September 24, 2004, 10:39:13 PM »
The . tells acad to use the built-in command and not one that has be redefined.
In the case of the layer command the - tells acad to use the command line version of the
command and not the dialog box version.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

danny

  • Guest
dimension lisp works in 2000 but not in 2004
« Reply #13 on: September 24, 2004, 10:53:53 PM »
cool..
I have one more problem though. I just updated my dimension lisp file, per CAB's info, but now my icon buttons don't work.  I would like add a link so that you can view the intire folder of icon's and lisp, etc. but don't know how to do that in this forum?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
dimension lisp works in 2000 but not in 2004
« Reply #14 on: September 24, 2004, 11:00:01 PM »
Here is another way to do your lisp.
Code: [Select]
(defun c:diml1 ();Sets Text leader to Full scale
  (dsetup "a-anno-text" "r" "l1")
  (command "_.qleader")
  (princ)
)

 ;Sets Text leader to 6" scale (half size)
(defun c:diml2 ()
  (dsetup "a-anno-text" "r" "l2")
  (command "_.qleader")
  (princ)
)
 
 ;Sets Text leader to 3" scale
(defun c:diml4 ()
  (dsetup "a-anno-text" "r" "l4")
  (command "_.qleader")
  (princ)
)

(defun c:dimm1 ();Sets dimension to Full scale
  (dsetup "a-anno-dims" "g" "m1")
  (command ".dimlinear")
  (princ)
)

 ;Sets dimension to 6" scale (half size)
(defun c:dimm2 ()
  (dsetup "a-anno-dims" "g" "m2")
  (command ".dimlinear")
  (princ)
)

 ;Sets dimension to 3" scale
(defun c:dimm4 ()
  (dsetup "a-anno-dims" "g" "m4")
  (command ".dimlinear")
  (princ)
)


;;======================================
;;  Function to change layer & dimstyle
;;======================================
(defun dsetup (lay col dstyle / oldcmdecho)
  (setq oldcmdecho (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (if (setq lyr (tblsearch "layer" lay))
    (command ".-layer" "m" lay "")
    (command ".-layer" "m" lay "c" col "" "")
  )
  (command ".units" "4" "" "" "" "" "")
  (if (null (setq dstl (tblsearch "dimstyle" dstyle)))
    (command ".insert"
             (strcat "c:/cadmenu/blocks/" dstytle ".dwg")
             ^c)
  )
  (command ".dimstyle" "r" dstyle)
  (setvar "cmdecho" oldcmdecho)
) ; defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.