Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/26/2024 in all areas

  1. when I check each line the error doesn't appear, but when I run the program it appears again.
    1 point
  2. @Steven P you hit the nail on the head with your second response I knew that was the issue just didn't know how to verbalise it so thanks. both your first and second bits of code works perfectly, although like you I prefer the second option its so much neater. in the below you mention the +1 on the listindex. I'm confused with this, when I run the parts individually in AutoCAD both of the layerlist1 and listindex end up at the same number (23) so why start with +1 on the list index? This second option looks so much neater. Am I write in my understanding that you don't need to set the variables before the while loop because the loop will start at the first listindex number, set those variables, and then loop through. This is all so I know for future reference ( I prefer to learn and understand rather than just take and use the code). Thanks.
    1 point
  3. I made a new thread for your question.
    1 point
  4. In fact my intention was simple, in order to clean up the [BBcodes] within the new code tags in this forum. Therefore, IMO optimized with CLIPBOARD without using 'getfiled' is much more convenient, isn't it? code updated - post#1 Copy text (from forum) -> run 'FORUM' (in ACAD) -> [Ctrl+V] Paste (in forum active editor) Done!
    1 point
  5. p/s: i recall there was discussions regarding LISP code tags schema at theswamp.org but i couldn't find it now
    1 point
  6. Here's another example demonstrating how to synchronise attribute values between layouts: (defun c:syncatts ( / ent enx idx lst sel ) (while (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect source block: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil) ( (or (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent))))) (/= 1 (cdr (assoc 66 enx))) ) (princ "\nSelected object is not an attributed block.") ) ) ) ) (if (and ent (setq lst (LM:getattributes ent) sel (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 410 (strcat "~" (getvar 'ctab))))) ) ) (repeat (setq idx (sslength sel)) (LM:setattributevalues (ssname sel (setq idx (1- idx))) lst) ) ) (princ) ) ;; Get Attributes - 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:getattributes ( blk / enx ) (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))) (cons (cons (cdr (assoc 2 enx)) (cdr (assoc 1 enx)) ) (LM:getattributes blk) ) ) ) ;; 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 ) (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))) (if (setq itm (assoc (cdr (assoc 2 enx)) lst)) (progn (if (entmod (subst (cons 1 (cdr itm)) (assoc 1 enx) enx)) (entupd blk) ) (LM:setattributevalues blk lst) ) (LM:setattributevalues blk lst) ) ) ) (princ) The above program uses functions from my Attribute Functions library. The code will currently iterate over all attributed blocks residing in layouts other than the current layout, and will populate all attributes with tags matching those found in the selected source block; the program could therefore be made more efficient by including a block name filter in the ssget filter list, however, I was not aware of the block names you were using and so left it generic. Lee
    1 point
×
×
  • Create New...