progeCAD support, tips and troubleshooting forum. progeCAD works very similar to some versions of AutoCAD. Moderated.

Moderators: caddit, Moderators

#1623 by gddesign
Mon Sep 12, 2011 1:45 pm
Can anyone help with question why this lisp crashes progeCAD?
Code: Select all; Dim2asoc.Lsp - This routine changes all ASSOCIATIVE dimensions
;                that have had their values changed by the user
;                and resets them all to their default values.
;                Warning - works on all layers, whether frozen or not.
;
(defun c:dim2asoc( / ss e ent n spin c )
   (defun spin( c )
      (cond
         ((= c  "|") "/")
         ((= c  "/") "-")
         ((= c  "-") "\\")
         ((= c "\\") "|")
      )
   )
   (if
      (and
         (setq ss (ssget "x" '((0 . "dimension"))))
         (progn
            (initget "Yes No")
            (= "Yes" (getkword "\nThis function will convert ALL dimensions to their default values. \nContinue?  Yes/<No>: "))
         )
      )
      (progn
         (princ (strcat "\n" (itoa (sslength ss)) " Dimensions to update"))
         (setq n -1 c "|")
         (princ "\nModifing dimension entity definitions |")
         (while (setq e (ssname ss (setq n (1+ n))))
            (princ (chr 8))(princ (setq c (spin c)))
            (entmod (list (cons -1 e) (cons 1 "")))
         )
      )
   ;else
      (princ "\nNo dimensions to update")
   )
   (princ "\n Enter DIM2ASOC to start")
   (princ)
)

#1626 by caddit
Tue Sep 20, 2011 10:00 am
gddesign,

We have discussed this with one of the developers. It seems that so far you can't specify a partial entmod list. As a work-around you should entget first, modify and then entmod changed list as below:
Code: Select all; Dim2asoc.Lsp - This routine changes all ASSOCIATIVE dimensions
;                that have had their values changed by the user
;                and resets them all to their default values.
;                Warning - works on all layers, whether frozen or not.
;
(defun c:dim2asoc( / ss e ent n spin c )
   (defun spin( c )
      (cond
         ((= c  "|") "/")
         ((= c  "/") "-")
         ((= c  "-") "\\")
         ((= c "\\") "|")
      )
   )
   (if
      (and
         (setq ss (ssget "x" '((0 . "dimension"))))
         (progn
            (initget "Yes No")
            (= "Yes" (getkword "\nThis function will convert ALL dimensions to their default values. \nContinue?  Yes/<No>: "))
         )
      )
      (progn
         (princ (strcat "\n" (itoa (sslength ss)) " Dimensions to update"))
         (setq n -1 c "|")
         (princ "\nModifing dimension entity definitions |")
         (while (setq e (ssname ss (setq n (1+ n))))
            (princ (chr 8))(princ (setq c (spin c)))
            (setq entlist (entget e))
            (setq newEntList (subst (cons 1 "") (assoc 1 entlist) entlist))
            (entmod newEntList)
         )
      )
   ;else
      (princ "\nNo dimensions to update")
   )
   (princ "\n Enter DIM2ASOC to start")
   (princ)
)


This is being looked at for next year's development in progeCAD 2012.

#1712 by gddesign
Fri Dec 16, 2011 11:00 pm
Thanks for your help sorting this out. Much appreciated.