Lee Chu Chu Posted February 4, 2015 Posted February 4, 2015 There are multiple attributes that I want to be able to increment by 1. However there are a couple of problems, there are different attributes but I want to be able to select all of them and I the value that I want to increment by 1 has a letter before it. Quote
Tharwat Posted February 4, 2015 Posted February 4, 2015 Can you give more details with an example drawing or a snapshot ? Quote
Lee Mac Posted February 4, 2015 Posted February 4, 2015 This program could be modified to allow multiple selection of attributed blocks. Quote
ghostware Posted February 4, 2015 Posted February 4, 2015 ATT-DEC.lsp (Increase or Decrease Attribute Value) Option: Process all or selection Option: Numbers of precision Option: Add + symbol to positive value ATT-DEC.LSP Quote
samifox Posted February 5, 2015 Posted February 5, 2015 ;; window select block with attribute which has attribute starting with a latter ;; advance it by 1 (setq *inc* 1 i 0 ) (sssetfirst nil nil) (defun c:incatt (/ x ss ent i) (if (setq ss (ssget ":L" '((0 . "INSERT") (66 . 1)))) (repeat (setq i (sslength ss)) (setq ent (entget (entnext (ssname ss (setq i (1- i)))))) (if (= (cdr (assoc 0 ent)) "ATTRIB") (if (wcmatch (cdr (setq n (assoc 1 ent))) "@*") (progn (setq x (+ *inc* (atoi (substr (cdr (assoc 1 ent))2)))) (setq x (strcat (substr (cdr n) 1 1) (itoa x))) (entmod (subst (cons 1 x) n ent)) ) ) ) ) ) ) Quote
Tharwat Posted February 5, 2015 Posted February 5, 2015 @ samifox You have lots of things to consider in your codes . 1- Since that you considered a static number to add to the text string in attributes , you can replace the global variable *inc* with number 1 2- You did set the variable ( i ) with zero and reset the same variable with the number of object in the selection set , so it is useless . 3- Your codes would modify the first attribute object if it was the first object crated in the block and it has a character as a starting of the text string . 4- Finally , you need to add while function to cycle through all objects in the selection set ( Block Definitions ) . Hope this help . Quote
Lee Chu Chu Posted February 5, 2015 Author Posted February 5, 2015 That code doesn't do anything of the sort/ anything that I want it to. It just shows me the properties of all the attributes that I have selected. I tried modifying the code but to no avail. Quote
Lee Chu Chu Posted February 5, 2015 Author Posted February 5, 2015 All I want the program to do is to select the multiple types of attributes and just increment the particular tag for the attribute called "CCTNUM" by 1. I don't want any options, just increment Quote
Lee Chu Chu Posted February 6, 2015 Author Posted February 6, 2015 I have managed to get the code to work but it increments the attribute tag and I am unable to find the associate tag for the value I want to change. 4 found ((-1 . <Entity name: 7f6ce7fc8b0>) (0 . "ATTRIB") (330 . <Entity name: 7f6ce7fc8a0>) (5 . "7EB") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "ESYMB_35") (6 . "Continuous") (100 . "AcDbText") (10 -43270.9 -15513.9 0.0) (40 . 250.0) (1 . "P4") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "ISOCP") (71 . 0) (72 . 1) (11 -43078.2 -15388.9 0.0) (210 0.0 0.0 1.0) (100 . "AcDbAttribute") (280 . 0) (2 . "DB DESIGNATION") (70 . 0) (73 . 0) (74 . 2) (280 . 0)) This is what is outputs and it changes the (1.P4) value but theres another value for the attribute that has the value something like E1. That is the one that I want to change. Quote
Tharwat Posted February 6, 2015 Posted February 6, 2015 Try this program . (defun c:Test ( / ss ) ;;; Tharwat . 06.02.2015 ;;; (if (setq ss (ssget "_:L" '((0 . "INSERT")(66 . 1)))) ((lambda ( x / sn st ) (while (setq sn (ssname ss (setq x (1+ x)))) (vl-some '(lambda (v) (if (and (eq (strcase (vla-get-tagstring v)) "CCTNUMBERS") (wcmatch (setq st (vla-get-textstring v)) "@*#") ) (progn (vla-put-textstring v (strcat (substr st 1 1) (itoa (1+ (read (substr st 2)))))) t) )) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes) ))) -1 ) ) (princ) ) (vl-load-com) Quote
samifox Posted February 6, 2015 Posted February 6, 2015 Try this program . (defun c:Test ( / ss ) ;;; Tharwat . 06.02.2015 ;;; (if (setq ss (ssget "_:L" '((0 . "INSERT")(66 . 1)))) ((lambda ( x / sn st ) (while (setq sn (ssname ss (setq x (1+ x)))) (vl-some '(lambda (v) (if (and (eq (strcase (vla-get-tagstring v)) "CCTNUMBERS") (wcmatch (setq st (vla-get-textstring v)) "@*#") ) (progn (vla-put-textstring v (strcat (substr st 1 1) (itoa (1+ (read (substr st 2)))))) t) )) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes) ))) -1 ) ) (princ) ) (vl-load-com) i really like your code ...so efficient! Quote
Tharwat Posted February 6, 2015 Posted February 6, 2015 i really like your code ...so efficient! Thank you samifox , I am happy to hear that . Quote
Kareca_78 Posted November 5, 2021 Posted November 5, 2021 I´m trying to increment the sum of attributes from one dinamic block to another dinamic block. Each block have 3 equally named attributes from A to C. Then i fill each attribute with numbers for example "A" = 1, "B"=1, "C=1 into block "1" and "A" = 2, "B"=2, "C=2 into block "2". My goal is to select block "1" and then block "2" and add the sum directly to block "2" attributes. Is this possible? Thanks in advance! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.