Jump to content

Change Attribute-value into blocks by CommandLine?


Recommended Posts

Posted

Well, i am relly newbie programing in AutoLisp, but i would like send you a question about renaming "attribute value" into a block with the commandLine I.ve got this problem, a topography plan with more or less 4000 points (NEZ) with not description into theirs attributes, because these descrition are in a outside text so i would like to put all descrition-value into the attribute-block to work in Civil3D More problems, all block are into the same layer : "PUNTOS G1" and finally problem, all blocks have got the same name: "PUNTO" Well, in any case i will have to click into each block to configure their new attribute-value, in the attribute-tag "Codigo". See the picture. thump_8304129eattedit.jpg 1- cannot use "-eattedit",becuuse promp the dialog box 2- cannot use "-attedit", for the same reason 3- cannot use "-atredit" into the commandline Command: -attedit Edit attributes one at a time? [Yes/No] : n Performing global editing of attribute values. Edit only attributes visible on screen? [Yes/No] : n Drawing must be regenerated afterwards. Enter block name specification : ; all block have got he same name Enter attribute tag specification : Codigo Enter attribute value specification : 4090 attributes selected. Enter string to change: Enter new string: PDZ If i use this command, i will rename all attribute-value for all block in the drawing [and i have to set 10 values for diferents kind of points] a)Command: (car(entsel)) Designe objeto: ; give me the entity name but "-attedit" require for the block-name (wicth is the same for all the block-points into the dwg) b) i found this script:

  (if (setq ent(entsel "\n Select a Block: ")) ;- Let the user select a block (progn (setq en(car ent)) ;- Get the entity name of the block (setq enlist(entget en)) ;- Get the DXF group codes (setq blkType(cdr(assoc 0 enlist))) ;- Save the type of entity (if (= blkType "INSERT") ;- If the entity type is an Insert entity (progn (if(= (cdr(assoc 66 enlist)) 1) ;- See if the attribute flag equals one (if so, attributes follow) (progn (setq en2(entnext en)) ;- Get the next sub-entity (setq enlist2(entget en2)) ;- Get the DXF group codes (while (/= (cdr(assoc 0 enlist2)) "SEQEND") ;- Start the while loop and keep ;- looping until SEQEND is found. (princ "\n ") ;-Print a new line (princ enlist2) ;- Print the attribute DXF group codes (setq en2(entnext en2)) ;- Get the next sub-entity (setq enlist2(entget en2)) ;- Get the DXF group codes ) ) ) ;- Close the if group code 66 = 1 statement ) ) ;- Close the if block type = "ATTRIB" statement ) ) ;- Close the if an Entity is selected statement  

wich give tthis info

 Select a Block:  ((-1 . ) (0 . ATTRIB) (330 . ) (5 . A89A) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . Nº PUNTO) (100 . AcDbText) (10 458491.0 4.47677e+006 575.23) (40 . 0.75) (1 . 3691) (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . Standard) (71 . 0) (72 . 0) (11 0.0 0.0 575.23) (210 0.0 0.0 1.0) (100 . AcDbAttribute) (280 . 0) (2 . NPUNTO) (70 . 0) (73 . 0) (74 . 0) (280 . 0))  ((-1 . ) (0 . ATTRIB) (330 . ) (5 . A89B) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . COTA Z) (100 . AcDbText) (10 458493.0 4.47677e+006 575.23) (40 . 0.75) (1 . 575.23) (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . Standard) (71 . 0) (72 . 0) (11 0.0 0.0 575.23) (210 0.0 0.0 1.0) (100 . AcDbAttribute) (280 . 0) (2 . COTA) (70 . 0) (73 . 0) (74 . 0) (280 . 0))  ((-1 . ) (0 . ATTRIB) (330 . ) (5 . A89C) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . CODIGOS 2) (100 . AcDbText) (10 458493.0 4.47677e+006 575.23) (40 . 0.75) (1 .  ) (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . Standard) (71 . 0) (72 . 0) (11 0.0 0.0 575.23) (210 0.0 0.0 1.0) (100 . AcDbAttribute) (280 . 0) (2 . CODIGO) (70 . 0) (73 . 0) (74 . 0) (280 . 0))  ((-1 . ) (0 . ATTRIB) (330 . ) (5 . A89D) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . 0) (100 . AcDbText) (10 458493.0 4.47676e+006 575.23) (40 . 0.75) (1 . 1) (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . Standard) (71 . 0) (72 . 0) (11 0.0 0.0 575.23) (210 0.0 0.0 1.0) (100 . AcDbAttribute) (280 . 0) (2 . NIVEL) (70 . 1) (73 . 0) (74 . 0) (280 . 0))((-1 . ) (0 . "SEQEND") (330 . ) (5 . "A89E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "PUNTOS G1") (-2 . ))  

where codes (1 . ????) (2 . ????) give me information about ATTRIBUTE TAGS & ATTRIBTE-VALUES But in any case i don´´t know how to change into (2 . CODIGO) the real Value (1 . ???) actually blank So, will have the best decision,.. in any case i will have to click in each point one to one. 1. selecct one by one each point [with the same attribute value to be changed] into different layer to copy into another drawing and then apply "-atredit" to all of them 2. try to write a simple scrip in AutoLips to change these attribute value in each point many thanks for all best regards AARi

Posted

Have a look at this written in VL I find a bit easier to understand compared to nextent and assoc's when learning it chnges a couple of attribute values in 2 blocks.

 

; changes to issued for construction
: thanks to lee mac for original code
(vl-load-com)
; 1.  Get current date in mm/dd/yy format.
(defun ddmmyy (/ x today)
    (setvar "cmdecho" 0)
    (setq x (getvar "CDATE"))                 ; get current date
    (setq today ( rtos x 2 4))                    ; convert to a string
    (setq date (strcat (substr today 7 2) "."    (substr today 5 2) "." (substr today 3 2) ))
)

(setq oldtag1 "DRAWING_STATUS") ;attribute tag name
(setq newstr1 "ISSUED FOR CONSTRUCTION")
(setq oldtag2 "REV_NO")  ;attribute tag name
(setq newstr2 "0")
(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "DA1DRTXT"))))
(setq inc (sslength ss1))
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
) ; end if
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
) ; end if
) ; end for
) ;end repeat
(setq oldtag1 "REV-NO")
(setq newstr1 "0")
(ddmmyy)
(setq oldtag2 "DATE")
(setq newstr2 date)
(setq oldtag3 "AMENDMENT")
(setq newstr3 "ISSUED FOR CONSTRUCTION")
(setq ss2 (ssget "x"  '((0 . "INSERT") (2 . "REVTABLE"))))
(setq inc (sslength ss2))
(repeat inc
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss2 (setq inc (1- inc)))) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
)
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
)
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr3) 
)
)
)
(setq ss1 nil)
; (setq ss2 nil)
(princ)

Posted

many thanks BIGAL

 

I will start to study the code ... [no easy or me, seams VisualLisp .arx]

 

AARi

Posted

look for words like 'getattributes tagstring textstring

get is to retrieve put is to change

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...