Ark Angel Posted August 4, 2015 Share Posted August 4, 2015 Is there a way of editing an attribute of a block so it will add a constant number (say 5) to all values in the block across the drawing. e.g. Assume 'A 125' and 'A 126' are blocks, can I edit the attribute so they become 'A 130' and 'A 131' and so on. Similiar to adding a formula to a cell in MS Excel. Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 4, 2015 Share Posted August 4, 2015 You should give Lee-Mac's Attribute Modification Suite seems to fit your situation. Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 Thanks commando but it doesn't seem to do the trick unless I'm using it improperly. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 4, 2015 Share Posted August 4, 2015 This program could be modified to operate with attributes. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2015 Share Posted August 4, 2015 Welcome to CADTutor. Is the number always at the end ? Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 4, 2015 Share Posted August 4, 2015 Thanks commando but it doesn't seem to do the trick unless I'm using it improperly. I misread your original post. Sorry about that! Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 Yes. The default, prompt and tag are just 'A' before the block is created. What I want to do is retain the existing value in all blocks, but add 302. So when the block is redefined it will read ' A + 302 ' Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2015 Share Posted August 4, 2015 You want to sum current number in attribute string with a specific number or concatenate current attribute string with a number ? Did you try the program that posted by Lee above ? Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 Tharwat, The former, add 302 to random numbers entered as an attribute value in a block. had to look up what 'concatenate' meant. Thanks. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2015 Share Posted August 4, 2015 had to look up what 'concatenate' meant. It means to append two or more strings with each others . Can you upload a sample drawing or a snapshot ? Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 I dont know if you can see this but on the the left is the unexploded block with values entered, on the right the exploded block. I want to add 302 to the digits after the B. There are about 400 of the same block in the drawing and they all need to have 302 added to the value. looking for an easy (quick) fix. I have about 10 of these drawings to change, each with diffrent values, some need to add 32, some 24, some 619 etc. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2015 Share Posted August 4, 2015 Try this : (defun c:Test (/ st s) ;; Tharwat 04.Aug.2015 ;; (if (and (/= "" (setq st (getstring "\nEnter a string to add to attributes in blocks:"))) (princ "\nSelect Attributed Blocks") (setq s (ssget "_:L" '((0 . "INSERT")(66 . 1)))) ) ((lambda (i / sn) (while (setq sn (ssname s (setq i (1+ i)))) (mapcar '(lambda (u) (vla-put-textstring u (strcat (vla-get-textstring u) st))) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes) ) )) -1) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 I'm not really up on running lsp routines.....how do I make it a .lsp instead of .txt Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2015 Share Posted August 4, 2015 Open Notepad with new file , copy and paste the codes inside that file then save it with any name you like with extension .lsp then go back to Autocad and run the command appload or ap then select the previous saved file and then success , type test to run the lisp routine . Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 It just adds '302' to the end of the text. i.e. 12345 becomes 12345302 not 12647 12345 + 302 ------- 12647 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2015 Share Posted August 4, 2015 It just adds '302' to the end of the text. i.e. 12345 becomes 12345302 not 12647 12345 + 302 ------- 12647 You just answered my question that I asked you along replies ago . I need to go now and if no one gave you a solution till tomorrow , I would be back to you to write a new program . Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 4, 2015 Author Share Posted August 4, 2015 Cheers for you time...sorry it took me so long to explain what I needed. Laters. Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 5, 2015 Author Share Posted August 5, 2015 Anybody any ideas with this one??? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 6, 2015 Share Posted August 6, 2015 Sorry for late reply , I had to finish my urgent work first . Try this program and let me know. (defun c:Test (/ s val) ;; Tharwat 06.Aug.2015 ;; (if (and (/= "" (setq val (getstring "\nEnter a number to add to attributes in blocks :" ) ) ) (numberp (read val)) (princ "\nSelect Attributed Blocks") (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1)))) ) ((lambda (i / sn str l no st) (while (setq sn (ssname s (setq i (1+ i)))) (mapcar '(lambda (u) (setq str (vla-get-textstring u) l nil no nil st nil l (vl-string->list str) ) (mapcar '(lambda (n) (if (< 47 n 58) (setq no (append no (list n))) (setq st (append st (list n))) ) ) l ) (if no (vla-put-textstring u (vl-string-subst (itoa (+ (read val) (read (vl-list->string no)))) (vl-list->string no) str ) ) ) ) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes) ) ) ) -1 ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
Ark Angel Posted August 6, 2015 Author Share Posted August 6, 2015 Thanks for that...I'll give it a go later...got seconded onto a different job. Quote Link to comment Share on other sites More sharing options...
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.