- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Dimension layer lisp for 2015
I have a lisp that we use at work for putting dimensions automatically into the "DIMENSION" layer. It worked in the past for AutoCAD 2012, but for some reason does not work for 2015. Does anyone have an idea what might be wrong or what would have changed? I'm not exactly a code guy, so I've struggled a little... (someone else originally wrote this lisp).
Thanks for your help!
;;;************************************** Dimension Redefinition ******************************************
;;;
;;; This program Redefines the Dimension commands. The new command incorperates a checks for the dimension
;;; layer and
;;;
;;;
;;;
;;;
;;;********************************************************************************************************
(defun layrchek (layr colr lstyl / layr colr lstyl chklyr)
(setq layr (strcase layr)
colr (strcase colr)
lstyl (strcase lstyl)
chklyr (tblsearch "layer" layr)
)
(if chklyr
(progn
(if (or (equal colr nil) (equal colr ""))
(setq colr (itoa (cdr (assoc 62 chklyr))))
)
(if (or (equal lstyl nil) (equal lstyl ""))
(setq lstyl (cdr (assoc 6 chklyr)))
)
(command "_.-layer" "on" layr "t" layr "s" layr
"u" layr "c" colr layr "l" lstyl layr
""
)
)
(progn
(if (or (equal colr nil) (equal colr ""))
(setq colr "7")
)
(if (or (equal lstyl nil) (equal lstyl ""))
(setq lstyl "CONTINUOUS")
)
(command "_.-layer" "m" layr "u" layr "c" colr layr "l" lstyl layr
"")
)
)
(princ)
)
(setvar "cmdecho" 0)
(if (not (tblsearch "layer" "dimension"))
(layrchek "dimension" "green" "")
)
(setq dmclst (list "dimlinear" "dimaligned"
"dimangular" "dimbaseline"
"dimcenter" "dimcontinue"
"dimradius" "dimdiameter"
"dimordinate"
)
)
(foreach item dmclst
(command "undefine" item)
(setq cmd (strcat "c:" item))
(if (not (eval (read cmd)))
(eval
(read
(strcat
"(defun "
cmd
" ()"
"(setq oldlayer (getvar \"CLAYER\") oldos (getvar \"OSMODE\"))"
"(setvar \"cmdecho\" 0)"
"(command \"._undo\" \"m\")"
"(setq lyr (getvar \"clayer\"))"
"(setvar \"clayer\" \"dimension\")"
"(setvar \"cmdecho\" 1)"
"(command \""
(strcat "_.acad_dim." item)
"\")"
"(while (> (getvar \"cmdactive\") 0) (command pause))"
"(setvar \"cmdecho\" 0)"
"(setvar \"clayer\" lyr)"
"(setvar \"CLAYER\" oldlayer)"
"(setvar \"OSMODE\" oldos)"
"(princ)"
")"
)
)
)
)
)
(princ)
(command "undefine" "qleader")
(defun c:qleader ()
(if (tblsearch "layer" "dimension")
(setvar "clayer" "dimension")
(layrchek "dimension" "green" "")
)
(command "_.acad_dim.qleader")
(princ)
)
(princ "\n Dimdef Loaded.")
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Hi. This lisp looks so bad that it hurts when I look at it ![]()
use this:
;--start--
(if (not (tblsearch "layer" "DIMENSION"))
(progn
(entmake
(list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 "DIMENSION")
'(70 . 0)
(cons 62 3)
)
)
) ;_progn
) ;_if
(if (not acdb:reactor)
(setq acdb:reactor
(vlr-AcDb-Reactor
nil
'((:vlr-objectappended . a+objcreated))
)
)
)
(defun a+objcreated (Reac Args / entl)
(setq entl (entget (cadr Args)))
(if (and entl
(member (cdr (assoc 0 entl)) (list "DIMENSION" "LEADER"))
(/= (cdr (assoc 8 entl)) "DIMENSION")
)
(progn
(setq entl (subst (cons 8 "DIMENSION") (assoc 8 entl) entl))
(entmod entl)
)
)
)
(princ "\n Dimdef Loaded for more go to www.cadaplus.com :)")
(princ)
;--end--
works much faster and it will not replace original dimenisons commands
best regards
Jedrzej Cytawa
APLUS SA
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Hey, thanks! It worked great except for one thing, the text for a leader remains in the "0" layer. Is there a way to incorporate that to take the "DIMENSION" layer as well? I tried playing around with it, but all I was able to do was make it not work at all....
Thanks again for figuring out the original lisp, its definitely a lot cleaner now!
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Otherwise, a similar reactive lisp could be created to temporarily change layer when your qleader command is invoked then switched back when it's finished.
SolidCAD Professional Services
http://www.solidcad.ca /
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@mathewkol wrote:
If you start using the MLEADER command instead, that LISP could be modified to put it on the correct layer. MLEADERs contain both the text and the leader as one object so you don't have to do any weird coding.
Otherwise, a similar reactive lisp could be created to temporarily change layer when your qleader command is invoked then switched back when it's finished.
I tried changing the (member (cdr (assoc 0 entl)) (list "DIMENSION" "LEADER")) line to (member (cdr (assoc 0 entl)) (list "DIMENSION" "MLEADER")) and it didn't put the MLeader on the Dimension layer. What did I miss?
~Nancy
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
So AutoCAD has started crashing since I loaded the lisp. The lisp works great as intended, but seems to have some side effects.
Anytime I "COPY" a view port in paperspace, AutoCAD fails everytime. I can create a new view port, but not copy one.
Also, about half of the time I try to create a new layout tab AutoCAD crashes.
I removed the lisp and these issues went away.
Any clue why this would be happening? I would like to keep this lisp, but don't want my AutoCAD crashing all the time.
Thanks,
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
use this:
(if (not (tblsearch "layer" "DIMENSION"))
(progn
(entmake
(list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 "DIMENSION")
'(70 . 0)
(cons 62 3)
)
)
) ;_progn
) ;_if
(if (not acdb:reactor)
(setq acdb:reactor
(vlr-AcDb-Reactor
nil
'((:vlr-objectappended . a+objcreated))
)
)
)
(if (not acdb:reactor2)
(setq acdb:reactor2
(vlr-command-reactor
nil
'((:vlr-commandended . a+commandended))
)
)
)
(defun a+objcreated (Reac Args / ent)
(setq ent (cadr args))
(if (and
(null (member ent objcreated))
)
(progn
(setq objcreated (cons ent objcreated))
)
)
)
(defun a+commandended (Reac Args / ent entl vla)
(foreach ent objcreated
(if (and
ent
(setq entl (entget ent))
(member (cdr (assoc 0 entl)) (list "DIMENSION" "LEADER"))
(/= (cdr (assoc 8 entl)) "DIMENSION")
)
(progn
(setq vla (vlax-ename->vla-object ent))
(vla-put-layer vla "DIMENSION")
(vla-update vla)
)
)
)
(setq objcreated nil)
(princ)
)
(princ "\n Dimdef Loaded for more go to www.cadaplus.com :)")
(princ)
now will not crash
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
AutoCAD seems to freeze for 5-10 minutes now any time I try to copy/paste from one drawing to another, or bring in a tool pallette file. I removed the dimesion lisp and AutoCAD seems to run fine. Any idea why this might be happening? It seems to get stuck on "EXECUTETOOL".
Thanks!