Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using the lisp to change the attribute tag value of the block

33 REPLIES 33
SOLVED
Reply
Message 1 of 34
toomohdi
7155 Views, 33 Replies

using the lisp to change the attribute tag value of the block

Hi

in attached file i have numbers of block with attribute that has 4 tags 1-code 2- Height( level or Z ) 3-alpha desc 4-point number.

the blocks were inserted in wrong location so i had to move the blocks to correct location so the value of height are not correct i need a lisp to chenge the value of the hieght tag base of insert point of block . appreciate it if sombody can help me. 

33 REPLIES 33
Message 21 of 34
toomohdi
in reply to: 3wood

thanks.

Message 22 of 34
paullimapa
in reply to: toomohdi

Fields are by default displayed in AutoCAD with a gray background.  To turn this off at the command prompt type:

FIELDDISPLAY

0

 

You can read up more on this:

http://exchange.autodesk.com/autocadlt/enu/online-help/browse#WS1a9193826455f5ffa23ce210c4a30acaf-4fe0.htm

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator | Layer Apps | List on Steroids | VP Zoom Scales
Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 23 of 34
toomohdi
in reply to: toomohdi

Pli
Thanks again.
Message 24 of 34
paullimapa
in reply to: hmsilva
Message 25 of 34
hmsilva
in reply to: paullimapa


@paullimapa wrote:

Thank you Henrique.

 


You're welcome, Paul.

 

Henrique

EESignature

Message 26 of 34
toomohdi
in reply to: paullimapa

Dear Paul Li,

 

Hi it has been long time from our last conversation on this subject and since that i am using and thanking you for your lisp.

one of our Client wants to all text be as a text and when i update the Z value by the lisp it will be converted to field objects, i could we add a commend to convert the field objects back to text after updating the entity.

Best Regards,

Message 27 of 34
paullimapa
in reply to: toomohdi

Actually if you do a search on this forum for lisp that converts Fields to Text, you'll find a number of examples like this one called RemoveFields:

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/convert-fields-within-attribute-to-mt...

 

I've modified it to accommodate for your Blocks named CROSS2.

 

Give the attached modified lisp file a try.

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 28 of 34
toomohdi
in reply to: paullimapa

Thanks,

but one qustion, could we make it convert all block at one?

Message 29 of 34
paullimapa
in reply to: toomohdi

I modified the code again to select all Blocks with Attributes.

But this is very dangerous because this will remove all the Fields and replace with Text.

This is not recommended.

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 30 of 34
toomohdi
in reply to: paullimapa

Thanks a lot and appreciate your help.i got the code in bellow from the link you sent to me and if you please look at it if it remove all the field as well or may cause a problem.

 

(vl-load-com)
(defun c:FLD2TXT (/ ss n bn an ad s)
(prompt
"Select the blocks you wish to remove the field links from: "
) ;_ end of prompt
(setq ss (ssget '((0 . "INSERT")))) ;Get selection set from user
(setq n 0) ;Initialize counter
;; Step through selection set one entity at a time
(while (< n (sslength ss))
(setq bn (ssname ss n)) ;Get the nth entity in the selection set
(setq an (entnext bn)) ;Get the next enity after bn
;; Step through each next entity until it is not an attribute
(while (and an ;Check if entity is found
(setq ad (entget an)) ;Get data
(= "ATTRIB" (cdr (assoc 0 ad))) ;Check if attribute
) ;_ end of and
(setq s (cdr (assoc 1 ad))) ;Get text value
(setq ad (subst (vl-list* 1 "") (assoc 1 ad) ad))
;Clear the attribute's value
(entmod ad) ;Modify the entity
(setq ad (subst (vl-list* 1 s) (assoc 1 ad) ad))
;Set the attribute's value back to only the text
(entmod ad) ;Modify the entity
(entupd an) ;Update screen to show change
(setq an (entnext an)) ;Get next entity
) ;_ end of while
(setq n (1+ n)) ;Increment counter
) ;_ end of while
(setq ss nil) ;Clear selection set
(gc) ;Clear unused memory
(princ)
) ;_ end of defun

 

Message 31 of 34
paullimapa
in reply to: toomohdi

I'm not sure why you are looking at this code FLD2TXT.lsp  What is the problem with the code I found & modified for you called RemoveFields.lsp?

 

Just so you know, the code FLD2TXT.lsp will require you to select Blocks without checking to see if those Blocks have Attributes.

 

If your purpose is for a lisp code that will automatically (without prompting for a selection set) search throughout the entire drawing for Blocks with Attributes and replace all Fields to Text, then FLD2TXT.lsp is not the solution.  But the modified RemoveFields.lsp will do this for you.

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 32 of 34
toomohdi
in reply to: paullimapa

Hi

when you mentioned not recommended i got afraid i am wondering if it possible to add RemoveFeide.lsp to to end of CZ.lsp to just revers the converting of Text to field after updating the field entity. just to make sure of cause any problem.the reason i look to FLD2TXT.lsp was the first version of RemoveFfeild.lsp was not do anything after loading and running it.but the latest one which you modified it run and work perfectly.thanks for that.

Mostly of my work is on topography survey drawing that contains different block name and when we do modifications ,we do modifying the location(X,Y,Z) of entire drawing including blocks at one so for that reason i needed a program to automatically modify or update Z value of all block in the entire drawing.

thanks for your continuously help.

 

 

Message 33 of 34
paullimapa
in reply to: toomohdi

Message 34 of 34
steven.bose
in reply to: toomohdi

;;Rebuilt block by exploding and doing a match text to attribute tag,

;;selected text then tag, repeating till done. My tags were all zero.

;;Could not find anything to fix tag based on prompt name. 

;;Pick a text and then a attribute tag to match value (cannot be in a block, need to explode first)
;;was made to rename tags, tags were all zero, needed new format x1, x2, x3 ect.

(DEFUN C:TEST ()

(SETQ A (ENTSEL " PICK TEXT"));;Pick text to match
(SETQ B (ENTGET (CAR A )));;gets info of text
(SETQ C (cdr (assoc 1 B)));;gets the assoc 1 info

(SETQ D (NENTSEL "Attribute"));;Pick Attribute to change
(SETQ E (ENTGET (CAR D)));;gets info of attibute
(setq F (subst (cons 2 C) (assoc 2 E) E));;swaps E info with C info and calls it F
(entmAKE F);;makes new enity F (attribute)

(SETQ G D);;makes copy of D's name
(COMMAND "_erase" G "" )
);;;;;;;END
(PRINC "TEST")

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost