Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/07/2019 in all areas

  1. (setq _inrange <=) (_inrange 2 1 2) >> nil (_inrange 1 2 3) >> T
    1 point
  2. You can achieve this with relatively few lines of code by making use of my Get Attribute Values & Set Attribute Values functions, as part of my Attribute Functions library. For example, consider the following code: (defun c:mapatts ( / dst map src ) (setq map '( ;; OLD_TAG . NEW_TAG ("REV0_DATE" . "REVSLOT1DATE") ) ) (defun selectattributedblock ( msg / ent enx ) (while (progn (setvar 'errno 0) (setq ent (car (entsel msg))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil ) ( (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent))))) (princ "\nThe selected object is not a block.") ) ( (/= 1 (cdr (assoc 66 enx))) (princ "\nThe selected block is not attributed.") ) ) ) ) ent ) (if (and (setq src (selectattributedblock "\nSelect source block: ")) (setq dst (selectattributedblock "\nSelect target block: ")) ) (LM:setattributevalues dst (mapcar '(lambda ( x ) (cons (cond ((cdr (assoc (car x) map))) ((car x))) (cdr x))) (LM:getattributevalues src) ) ) ) (princ) ) ;; Get Attribute Values - Lee Mac ;; Returns an association list of attributes present in the supplied block. ;; blk - [ent] Block (Insert) Entity Name ;; Returns: [lst] Association list of ((<tag> . <value>) ... ) (defun LM:getattributevalues ( blk / enx lst ) (while (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))) (setq lst (cons (cons (cdr (assoc 2 enx)) (cdr (assoc 1 (reverse enx))) ) lst ) ) ) (reverse lst) ) ;; Set Attribute Values - Lee Mac ;; Sets attributes with tags found in the association list to their associated values. ;; blk - [ent] Block (Insert) Entity Name ;; lst - [lst] Association list of ((<tag> . <value>) ... ) ;; Returns: nil (defun LM:setattributevalues ( blk lst / enx itm ) (while (and (setq blk (entnext blk)) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget blk)))))) (if (and (setq itm (assoc (cdr (assoc 2 enx)) lst)) (entmod (subst (cons 1 (cdr itm)) (assoc 1 (reverse enx)) enx)) ) (entupd blk) ) ) nil ) (princ) Here, you can populate the list at the top of the code with dotted pairs mapping the old attribute tags to their corresponding attribute tags within the new block (note that these are case-sensitive), per the existing example provided. The program will then extract the existing attribute tags & values from the selected source block, 'translate' the names of those attribute tags which in the list at the top of the program, and then populate all matching attributes in the target block.
    1 point
    Awesome! It's a very useful app. I use it all the time when I calculate the area.
    1 point
    Great solution! Suitable also for cadastral plans. Etc. The speed of work is particularly striking.
    1 point
×
×
  • Create New...