cyberactive Posted May 9, 2019 Share Posted May 9, 2019 Hello, I have a routine that edits the value of a block, what happens is that I have several of these blocks that are repeated in each plane, with this routine I can edit only one and the others change at the same time, what I want is add a DCL so that it can be edited from a DCL so I'm not calling one by one since I would have it in the values to edit. The operation of the routine is simple, call the command and ask for the name of the block then the new value and edit it in all that are equal, the blocks that have to be called are: TITULAR, CONYUGE, PUEBLO, MZ, MUNI1, MUNI2 (defun c:editag ( / tagname newv ss1 len count bn en el found) (setq tagname (getstring T "Block Name: ") newv (getstring T "New value: ")) (setq ss1 (ssget "x" '((0 . "insert") (66 . 1))) len (sslength ss1) count 0) (repeat len (setq bn (ssname ss1 count) en (entnext bn) el (entget en)) (while (and (= "ATTRIB" (dxf 0 el)) (/= "SEQEND" (dxf 0 el))) (if (= (dxf 2 el) (strcase tagname)) (progn (setq el (subst (cons 1 newv) (assoc 1 el) el)) (entmod el) (entupd bn) (setq found "yes") ) ) (setq en (entnext en) el (entget en)) ) (setq count (1+ count)) ) (if (/= found "yes") (princ "\nThere is no block.") ) (princ) ) (defun dxf (code elist) (cdr (assoc code elist)) ) (princ) I have attached the plan with the blocks to be edited with the editag command. Editag.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 10, 2019 Share Posted May 10, 2019 (edited) 1st step is to loop through the block names from a list is easier. Using (cons 2 blkname) with the ssget Your welcome to use this dcl library routine for input you would pass the block name and a default value could be blank. Looking at your dwg as they are single attributes makes it much easier. update attribute 0. ; replace block attribute multi block names ; By Alan H May 2019 ; AJH Consulting (defun c:replaceblk ( / oldsnap lst blk x y att ans) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq oldsnap (getvar 'osmode)) (setq lst '()) (setvar 'osmode 512) (while (/= (setq obj (entsel "Pick block Enter to exit")) nil) (setq bname (vla-get-name (vlax-ename->vla-object (car obj)))) (setq lst (cons bname lst)) (princ "\n") ) (repeat (setq x (length lst)) (setq blk (nth (setq x (- x 1)) lst)) (setq ss (ssget "x" (list (cons 0 "Insert") (cons 2 blk)))) (setq ans (nth 0 (AH:getvalsm (list (strcat "Attribute replacement " blk) "New attribute" 25 24 "1-1" )))) (repeat (setq y (sslength ss)) (setq blk (vlax-ename->vla-object (ssname ss (setq y (- y 1))))) (setq att (vlax-invoke blk 'getattributes)) (vla-put-textstring (nth 0 att) ans) ) ) (setvar 'osmode oldsnap) (princ) ) (c:replaceblk) Edited May 10, 2019 by BIGAL Quote Link to comment Share on other sites More sharing options...
cyberactive Posted May 10, 2019 Author Share Posted May 10, 2019 (edited) hello, something like this link, which detects the values and that are modified from a dcl, I do not want to replace the block, I wish only to replace the value, in the dwg it can be modified massively with the editag command but I want it to be from a DCL . https://www.afralisp.net/dialog-control-language/tutorials/dcl-without-the-dcl-file-part-2.php Edited May 10, 2019 by cyberactive Quote Link to comment Share on other sites More sharing options...
cyberactive Posted May 10, 2019 Author Share Posted May 10, 2019 (edited) SOMETHING LIKE THAT Edited May 10, 2019 by cyberactive Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 11, 2019 Share Posted May 11, 2019 I started doing the dcl as you have shown as part of the Multi gevals. It is dynamic in that it is not hard coded so you can have as many block names as you like. Working on your sample maybe tomorrow. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted May 13, 2019 Share Posted May 13, 2019 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Quote Link to comment Share on other sites More sharing options...
cyberactive Posted May 16, 2019 Author Share Posted May 16, 2019 On 5/10/2019 at 8:34 PM, BIGAL said: I started doing the dcl as you have shown as part of the Multi gevals. It is dynamic in that it is not hard coded so you can have as many block names as you like. Working on your sample maybe tomorrow. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 16, 2019 Share Posted May 16, 2019 Try this setting up a new laptop so have not dragged everything over yet. replace block attribute multi block names.lsp Quote Link to comment Share on other sites More sharing options...
catoscuro Posted June 17, 2019 Share Posted June 17, 2019 hi, I have the blocks title-2 and I want to change the attribute No. but it marks me the following "Command: (LOAD "C:/LISP/MasUsados/Bloques/replace block attribute multi block names.lsp") Pick block Enter to exit Pick block Enter to exit (545); error: bad argument type: lselsetp nil you could help me, thanks in advance DETALLES.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 17, 2019 Share Posted June 17, 2019 The code was done for a specific dwg, can you post a before and after dwg copy the blocks so can see change. I think you need something different. Quote Link to comment Share on other sites More sharing options...
catoscuro Posted June 17, 2019 Share Posted June 17, 2019 In general it is to change any attribute of the selected blocks SUSTITUCION.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 19, 2019 Share Posted June 19, 2019 (edited) Understand now you want to pick an attribute then jump to each block changing value. Old New etc I have nothing at moment. Edited June 19, 2019 by BIGAL 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.