blocks change when inserted

  • Thread starter Thread starter marybethoberlin
  • Start date Start date
M

marybethoberlin

I've tried searching for this, but I have no idea what I'm looking for... A new employee at our company says that at a previous job, the office had a block that could be repeatedly inserted and count up each time it was placed. For instance, "room number" block could be inserted, first click would place "Rm. 101", second click would place "Rm. 102", etc. She does not know how this was set up, or even what type/version of AutoCAD they used. Is this a customized item? Is it part of architectural desktop? This would be really useful, if we could figure it out. We have AutoCAD 2005.

Thanks!
Mary Beth
 
With the built in scheduling features of ADT door, window and room tags worked in the manner you described. I don't think that plain vanilla AutoCAD has the same scheduling features as ADT, so you'd need to look into some form of LISP routine that may be able to help.
 
is this any help?? load the .lsp file, type "countup" on the commad line
and click away...
 
Wow, I'm sure this will be useful for something, thanks! The blocks would be best, but sounds like those are only in ADT. This office won't be moving to that level anytime soon, so we'll still have to edit them one at a time. Glad I got that mystery solved.

Mary Beth
 
That lisp routine is certianly part of it. After I read "gman's" line I
remember seeing the (countup) as part of that tag. It's out there
somewhere, keep looking.
Paul
 
maybe someone smarter than me can come up with a routine that includes the
block :^)
 
Here you go-

Create yopur block with the correct insertion point and attributes then cut
and paste the following and replace the obvious.

use this format for the path

DRIVE:\\FILE FOLDER\\BLOCK_NAME_HERE.dwg


(defun c:lnm (/ new_num blk)
(setq blk "BLOCK_NAME_HERE")
(if (and (not (tblsearch "block" blk))
(not (setq blk (findfile "BLOCK PATH HERE")))
)
(alert (strcat "Routine requires attributed block \"lot number\" and I
could not find it."
"\nPlease make this block available and try again...."))
(progn
(createDict "jmm_Number")
(if (not (setq recList (getDictRec "jmm_Number" "last_num")))
(progn
(addDictRec "jmm_Number" "last_num" (list (cons 76 1)))
(setq recList (getDictRec "jmm_Number" "last_num"))
)
)
(if (not *last_num*)(setq *last_num* (cdr (car reclist))))
(cond
((setq new_num (getint (strcat "\nNumber to start numbering with ("
(itoa *last_num*)
") : ")))(start_lbl))
((setq new_num *last_num*)(start_lbl))
)
(princ)
)
)
)
(defun start_lbl (/ INSPT SCL)
(setq scl (getvar "dimscale"))
(while (setq insPt (getpoint "\nSelect next number Insertion Point: "))
(command "-insert" blk inspt scl scl 0.0 new_num)
(setq new_num (1+ new_num)
*last_num* new_num
)
(chgDictRec "jmm_Number" "last_num" (list (cons 76 *last_num*)))
)
)
;The following Dictionary functions are as posted to the
;Autodesk customization newsgroup by Juerg Menzi...he
;mentions that the origin is unknown.....
;
; -- Function CreateDict
; Creates a new or returns an existing dictionary.
; Arguments [Typ]:
; Nme = Name of the new dictionary [STR]
; Return [Typ]:
; > Entity name of new/existing dictionary [ENAME]
; Notes:
; None
;
(defun CreateDict (Nme / DicEnt NewDic TmpLst)
(if (not (setq NewDic (GetDictEnt Nme)))
(setq TmpLst '((0 . "DICTIONARY") (100 . "AcDbDictionary"))
DicEnt (entmakex TmpLst)
NewDic (dictadd (namedobjdict) Nme DicEnt)
)
NewDic
)
)
;
; -- Function DelDict
; Deletes the specified dictionary.
; Arguments [Typ]:
; Nme = Name of the dictionary to delete [STR]
; Return [Typ]:
; > Entity name [ENAME]
; Notes:
; None
;
(defun DelDict (Nme)
(dictremove (namedobjdict) Nme)
)
;
; -- Function AddDictRec
; Adds a record to a dictionary.
; Arguments [Typ]:
; Nme = Name of dictionary to access [STR]
; Key = Keyname for the record object [STR]
; Lst = Data list '((Key1 . Value1)...(Keyx . Valuex))

  • ; Return [Typ]:
    ; > Entity name of modified dictionary [ENAME]
    ; Notes:
    ; None
    ;
    (defun AddDictRec (Nme Key Lst / DicEnt TmpLst)
    (setq TmpLst (append
    '((0 . "XRECORD") (100 . "AcDbXrecord") (280 . 0))
    Lst
    )
    DicEnt (entmakex TmpLst)
    )
    (dictadd (GetDictEnt Nme) Key DicEnt)
    )
    ;
    ; -- Function GetDictRec
    ; Retrieves the data list by key from a dictionary.
    ; Arguments [Typ]:
    ; Nme = Name of dictionary to access [STR]
    ; Key = Keyname for the record object [STR]
    ; Return [Typ]:
    ; > Data list

    • ; Notes:
      ; None
      ;
      (defun GetDictRec (Nme Key)
      (cdr (cddddr (cddddr (dictsearch (GetDictEnt Nme) Key))))
      )
      ;
      ; -- Function ChgDictRec
      ; Redefines the specified record of a dictionary.
      ; Arguments [Typ]:
      ; Nme = Name of dictionary to access [STR]
      ; Key = Keyname for the record object [STR]
      ; Lst = Data list '((Key1 . Value1)...(Keyx . Valuex))

      • ; Return [Typ]:
        ; > Entity name of modified dictionary [ENAME]
        ; Notes:
        ; None
        ;
        (defun ChgDictRec (Nme Key Lst)
        (if (GetDictRec Nme Key)
        (progn
        (DelDictRec Nme Key)
        (AddDictRec Nme Key Lst)
        )
        )
        )
        ;
        ; -- Function DelDictRec
        ; Deletes the specified record from a dictionary.
        ; Arguments [Typ]:
        ; Nme = Name of dictionary to access [STR]
        ; Key = Keyname for the record object [STR]
        ; Return [Typ]:
        ; > Entity name of modified dictionary [ENAME]
        ; Notes:
        ; None
        ;
        (defun DelDictRec (Nme Key)
        (dictremove (GetDictEnt Nme) Key)
        )
        ;
        ; -- Function GetDictKeys
        ; Returns a list of keynames from the specified dictionary.
        ; Arguments [Typ]:
        ; Nme = Name of dictionary to access [STR]
        ; Key = Keyname for the record object [STR]
        ; Return [Typ]:
        ; > Key list

        • ; Notes:
          ; None
          ;
          (defun GetDictKeys (Nme / TmpLst)
          (cond
          ((setq TmpLst (GetDict Nme)) (GetMassoc 3 TmpLst))
          (T nil)
          )
          )
          ;
          ; -- Function GetDictKeysVals
          ; Returns a list of keynames with associated values from the
          ; specified dictionary.
          ; Arguments [Typ]:
          ; Nme = Name of dictionary to access [STR]
          ; Return [Typ]:
          ; > Key value list '((Key1 . Value1)...(Keyx . Valuex))

          • ; Notes:
            ; None
            ;
            (defun GetDictKeyVals (Nme)
            (mapcar
            '(lambda (l)
            (cons l (cdar (GetDictRec Nme l)))
            ) (GetDictKeys Nme)
            )
            )
            ;
            ; -- Function ListDicts
            ; Returns a list of all dictionaries in the current drawing.
            ; Arguments [Typ]:
            ; --- =
            ; Return [Typ]:
            ; > List of dictionaries

            • ; Notes:
              ; None
              ;
              (defun ListDicts ()
              (GetMassoc 3 (entget (namedobjdict)))
              )
              ;
              ; -- Function GetDict
              ; Retrieves the entity definition list of the specified dictionary.
              ; Arguments [Typ]:
              ; Nme = Name of the dictionary [STR]
              ; Return [Typ]:
              ; > Entity definition of dictionary

              • ; Notes:
                ; None
                ;
                (defun GetDict (Nme)
                (dictsearch (namedobjdict) Nme)
                )
                ;
                ; -- Function GetDictEnt
                ; Retrieves the entity name of the specified dictionary.
                ; Arguments [Typ]:
                ; Nme = Name of the dictionary [STR]
                ; Return [Typ]:
                ; > Entity name of dictionary [ENAME]
                ; Notes:
                ; None
                ;
                (defun GetDictEnt (Nme / TmpLst)
                (cond
                ((setq TmpLst (GetDict Nme)) (GetAssoc -1 TmpLst))
                (T nil)
                )
                )
                ;
                ; -- Function GetMassoc
                ; Get multiple associative values from a list.
                ; Arguments [Typ]:
                ; Key = Key to search [INT]
                ; Lst = Dotted pair list

                • ; Return [Typ]:
                  ; > List of values

                  • ; Notes:
                    ; Published by T.Tanzillo
                    ;
                    (defun GetMassoc (Key Lst)
                    (apply 'append
                    (mapcar
                    '(lambda (l) (if (eq (car l) Key) (list (cdr l)))) Lst
                    )
                    )
                    )
                    ;
                    ; -- Function GetAssoc
                    ; Get associative value from a list.
                    ; Arguments [Typ]:
                    ; Key = Key to search [INT]
                    ; Lst = Dotted pair list

                    • ; Return [Typ]:
                      ; > Value [ALL]
                      ; Notes:
                      ; None
                      ;
                      (defun GetAssoc (Key Lst)
                      (cdr (assoc Key Lst))
                      )

                      ;(princ "\n\nType LOTNUM to start.")

                      (princ)
 
Also make sure to rename any instance of "lot number" with the name of your
block. This is a routine that I use to create lot numbers in sub-divisions I
am certain that it will do the trick for you.


DAWGS FAN said:
Here you go-

Create yopur block with the correct insertion point and attributes then
cut and paste the following and replace the obvious.

use this format for the path

DRIVE:\\FILE FOLDER\\BLOCK_NAME_HERE.dwg


(defun c:lnm (/ new_num blk)
(setq blk "BLOCK_NAME_HERE")
(if (and (not (tblsearch "block" blk))
(not (setq blk (findfile "BLOCK PATH HERE")))
)
(alert (strcat "Routine requires attributed block \"lot number\" and I
could not find it."
"\nPlease make this block available and try again...."))
(progn
(createDict "jmm_Number")
(if (not (setq recList (getDictRec "jmm_Number" "last_num")))
(progn
(addDictRec "jmm_Number" "last_num" (list (cons 76 1)))
(setq recList (getDictRec "jmm_Number" "last_num"))
)
)
(if (not *last_num*)(setq *last_num* (cdr (car reclist))))
(cond
((setq new_num (getint (strcat "\nNumber to start numbering with ("
(itoa *last_num*)
") : ")))(start_lbl))
((setq new_num *last_num*)(start_lbl))
)
(princ)
)
)
)
(defun start_lbl (/ INSPT SCL)
(setq scl (getvar "dimscale"))
(while (setq insPt (getpoint "\nSelect next number Insertion Point: "))
(command "-insert" blk inspt scl scl 0.0 new_num)
(setq new_num (1+ new_num)
*last_num* new_num
)
(chgDictRec "jmm_Number" "last_num" (list (cons 76 *last_num*)))
)
)
;The following Dictionary functions are as posted to the
;Autodesk customization newsgroup by Juerg Menzi...he
;mentions that the origin is unknown.....
;
; -- Function CreateDict
; Creates a new or returns an existing dictionary.
; Arguments [Typ]:
; Nme = Name of the new dictionary [STR]
; Return [Typ]:
; > Entity name of new/existing dictionary [ENAME]
; Notes:
; None
;
(defun CreateDict (Nme / DicEnt NewDic TmpLst)
(if (not (setq NewDic (GetDictEnt Nme)))
(setq TmpLst '((0 . "DICTIONARY") (100 . "AcDbDictionary"))
DicEnt (entmakex TmpLst)
NewDic (dictadd (namedobjdict) Nme DicEnt)
)
NewDic
)
)
;
; -- Function DelDict
; Deletes the specified dictionary.
; Arguments [Typ]:
; Nme = Name of the dictionary to delete [STR]
; Return [Typ]:
; > Entity name [ENAME]
; Notes:
; None
;
(defun DelDict (Nme)
(dictremove (namedobjdict) Nme)
)
;
; -- Function AddDictRec
; Adds a record to a dictionary.
; Arguments [Typ]:
; Nme = Name of dictionary to access [STR]
; Key = Keyname for the record object [STR]
; Lst = Data list '((Key1 . Value1)...(Keyx . Valuex))

  • ; Return [Typ]:
    ; > Entity name of modified dictionary [ENAME]
    ; Notes:
    ; None
    ;
    (defun AddDictRec (Nme Key Lst / DicEnt TmpLst)
    (setq TmpLst (append
    '((0 . "XRECORD") (100 . "AcDbXrecord") (280 . 0))
    Lst
    )
    DicEnt (entmakex TmpLst)
    )
    (dictadd (GetDictEnt Nme) Key DicEnt)
    )
    ;
    ; -- Function GetDictRec
    ; Retrieves the data list by key from a dictionary.
    ; Arguments [Typ]:
    ; Nme = Name of dictionary to access [STR]
    ; Key = Keyname for the record object [STR]
    ; Return [Typ]:
    ; > Data list

    • ; Notes:
      ; None
      ;
      (defun GetDictRec (Nme Key)
      (cdr (cddddr (cddddr (dictsearch (GetDictEnt Nme) Key))))
      )
      ;
      ; -- Function ChgDictRec
      ; Redefines the specified record of a dictionary.
      ; Arguments [Typ]:
      ; Nme = Name of dictionary to access [STR]
      ; Key = Keyname for the record object [STR]
      ; Lst = Data list '((Key1 . Value1)...(Keyx . Valuex))

      • ; Return [Typ]:
        ; > Entity name of modified dictionary [ENAME]
        ; Notes:
        ; None
        ;
        (defun ChgDictRec (Nme Key Lst)
        (if (GetDictRec Nme Key)
        (progn
        (DelDictRec Nme Key)
        (AddDictRec Nme Key Lst)
        )
        )
        )
        ;
        ; -- Function DelDictRec
        ; Deletes the specified record from a dictionary.
        ; Arguments [Typ]:
        ; Nme = Name of dictionary to access [STR]
        ; Key = Keyname for the record object [STR]
        ; Return [Typ]:
        ; > Entity name of modified dictionary [ENAME]
        ; Notes:
        ; None
        ;
        (defun DelDictRec (Nme Key)
        (dictremove (GetDictEnt Nme) Key)
        )
        ;
        ; -- Function GetDictKeys
        ; Returns a list of keynames from the specified dictionary.
        ; Arguments [Typ]:
        ; Nme = Name of dictionary to access [STR]
        ; Key = Keyname for the record object [STR]
        ; Return [Typ]:
        ; > Key list

        • ; Notes:
          ; None
          ;
          (defun GetDictKeys (Nme / TmpLst)
          (cond
          ((setq TmpLst (GetDict Nme)) (GetMassoc 3 TmpLst))
          (T nil)
          )
          )
          ;
          ; -- Function GetDictKeysVals
          ; Returns a list of keynames with associated values from the
          ; specified dictionary.
          ; Arguments [Typ]:
          ; Nme = Name of dictionary to access [STR]
          ; Return [Typ]:
          ; > Key value list '((Key1 . Value1)...(Keyx . Valuex))

          • ; Notes:
            ; None
            ;
            (defun GetDictKeyVals (Nme)
            (mapcar
            '(lambda (l)
            (cons l (cdar (GetDictRec Nme l)))
            ) (GetDictKeys Nme)
            )
            )
            ;
            ; -- Function ListDicts
            ; Returns a list of all dictionaries in the current drawing.
            ; Arguments [Typ]:
            ; --- =
            ; Return [Typ]:
            ; > List of dictionaries

            • ; Notes:
              ; None
              ;
              (defun ListDicts ()
              (GetMassoc 3 (entget (namedobjdict)))
              )
              ;
              ; -- Function GetDict
              ; Retrieves the entity definition list of the specified dictionary.
              ; Arguments [Typ]:
              ; Nme = Name of the dictionary [STR]
              ; Return [Typ]:
              ; > Entity definition of dictionary

              • ; Notes:
                ; None
                ;
                (defun GetDict (Nme)
                (dictsearch (namedobjdict) Nme)
                )
                ;
                ; -- Function GetDictEnt
                ; Retrieves the entity name of the specified dictionary.
                ; Arguments [Typ]:
                ; Nme = Name of the dictionary [STR]
                ; Return [Typ]:
                ; > Entity name of dictionary [ENAME]
                ; Notes:
                ; None
                ;
                (defun GetDictEnt (Nme / TmpLst)
                (cond
                ((setq TmpLst (GetDict Nme)) (GetAssoc -1 TmpLst))
                (T nil)
                )
                )
                ;
                ; -- Function GetMassoc
                ; Get multiple associative values from a list.
                ; Arguments [Typ]:
                ; Key = Key to search [INT]
                ; Lst = Dotted pair list

                • ; Return [Typ]:
                  ; > List of values

                  • ; Notes:
                    ; Published by T.Tanzillo
                    ;
                    (defun GetMassoc (Key Lst)
                    (apply 'append
                    (mapcar
                    '(lambda (l) (if (eq (car l) Key) (list (cdr l)))) Lst
                    )
                    )
                    )
                    ;
                    ; -- Function GetAssoc
                    ; Get associative value from a list.
                    ; Arguments [Typ]:
                    ; Key = Key to search [INT]
                    ; Lst = Dotted pair list

                    • ; Return [Typ]:
                      ; > Value [ALL]
                      ; Notes:
                      ; None
                      ;
                      (defun GetAssoc (Key Lst)
                      (cdr (assoc Key Lst))
                      )

                      ;(princ "\n\nType LOTNUM to start.")

                      (princ)
 
Back
Top