Jump to content
cyberactive

edit attribute value of a block massively

Recommended Posts

cyberactive

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

Share this post


Link to post
Share on other sites
BIGAL
Posted (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 by BIGAL

Share this post


Link to post
Share on other sites
cyberactive
Posted (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 by cyberactive

Share this post


Link to post
Share on other sites
cyberactive
Posted (edited)
SOMETHING LIKE THAT

image.png.713a5a5a5712aa70d64dfdedff592c66.png

Edited by cyberactive

Share this post


Link to post
Share on other sites
BIGAL

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.

 

image.png.9ed5018a2790bc8fdacb0dbb7e14f809.pngimage.png.2e54866930d435e22ae94952b53d69a6.png

 

Share this post


Link to post
Share on other sites
cyberactive
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.

 

image.png.9ed5018a2790bc8fdacb0dbb7e14f809.pngimage.png.2e54866930d435e22ae94952b53d69a6.png

 

 

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...