Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Attedit script help

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
AcadAdamLT
6110 Views, 17 Replies

Attedit script help

Hi, trying to create a script but I can't get it to do what I want.

Here's the deal:

 

Command: -ATTEDIT

Edit attributes one at a time? [Yes/No] <Y>: n

Performing global editing of attribute values.
Edit only attributes visible on screen? [Yes/No] <Y>: n

Drawing must be regenerated afterwards.
Enter block name specification <*>: A3_ram_A4stamp

Enter attribute tag specification <*>: PROJ_NAMN

Enter attribute value specification <*>: *

1 attributes selected.
Enter string to change:
Enter new string: Traneberg

 

Everything works so far, the problem is that I want Autocad to replace the old value, what Autocad does is add the new string to the old Value, for example. If the old value was "Adam" and I use the command the new value would be "TranebergAdam".

Is there anyway to get this command to replace the existing value?

 

 

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
17 REPLIES 17
Message 2 of 18
pendean
in reply to: AcadAdamLT

Why not enter the "string to change" instead of leaving it blank? Seems to be a command requirement.

Message 3 of 18
AcadAdamLT
in reply to: pendean

The string to change differs from drawing to drawing.

I would like to use a wildcard match there but...

 

Change

Modifies a few characters of the attribute value.

Enter string to change: Enter string to change or press ENTER

Enter new string: Enter replacement string or press ENTER

Either string can be null. The ? and * characters are interpreted literally, not as wild-card characters.

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 4 of 18
pendean
in reply to: AcadAdamLT

Sorry, but at the commandline -ATTEDIT does not work that way, only as I noted.
Also note that EVERY instance of that block in the file also gets changed: might be fine if you have a one off block but disasterous if you do not.

 

Are you trying to automate some sort of FIND/REPLACE function in LT?

Message 5 of 18
AcadAdamLT
in reply to: pendean

Exactly what I'm trying to do, recieved a documentation from a client that I have to edit.

It contains about 20 drawings and about 200 layouts.

The block I'm trying to change is the titleblock in each layout...

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 6 of 18
pendean
in reply to: AcadAdamLT

Here is where you slap someone for not XREFing in a titleblock 🙂
One edit, one fix, all 20 drawings/200 layouts.

 

See this old tip:

http://forums.autodesk.com/t5/AutoCAD-LT-General/Batch-File-to-Change-attribute-definition-LT/td-p/4...

Message 7 of 18
AcadAdamLT
in reply to: pendean

Right now I feel more like beating someones car with a crowbar rather then slapping.

 

Thanks for the tip but won't help my case =/

 

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 8 of 18
hwalker
in reply to: AcadAdamLT

I've just been reading through the 2010 help online and it seems global editing can not do that.

 

If you edit each item individually you get a change/replace option.

 

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a91938...

 

Link to relevent section

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

Message 9 of 18
AcadAdamLT
in reply to: hwalker

Yea I read that while trying to figure it all out, editting them one by one looses all the functionality I was trying to archieve.

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 10 of 18
steven-g
in reply to: AcadAdamLT

If your attribute values contain capitals or special characters you will need to add to the script, it's longwinded but does the job. Change the extension to scr

EDIT I used the name 'three' for the attribute tag that will need changing to suit as well.

Message 11 of 18
AcadAdamLT
in reply to: steven-g

Hi Steven,

 

My Script does not differ from yours except I specify the block reference, problem is that Autocad won't replace the the current value, if you have an empty attribute the script works fine, but all my attributes to change already has a value that differs from layout to layout.

To change the existing Value I must specify the current value to change, that requires a "user input" which would destroy the whole idea with the script.

For this to work I need to somehow include in the script to first blank all the existing value and then assign new values, this I don't know how to archieve and I don't think it's even possible.

 

Thanks for your input.

 

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 12 of 18
steven-g
in reply to: AcadAdamLT

Did you look at the script, it goes through and blanks out the old text one character at a time then writes in the new text, but as I said in the first post it only works for lower case and numbers at the moment. If you use special characters or upper case then you would need to add to the script

Message 13 of 18
AcadAdamLT
in reply to: steven-g

Steven haha, ingenious 😉

Didn't get it at first, clever use of the command there, it will be one hell of a long script but it will save me a tremendous amount of time.

My good sir, I salute you!

Signature, sincerely... //Adam
AutoCad LT 2016
Give Kudos where credit is due, Mark "accepted as solution" if the post solved your question.
Message 14 of 18
steven-g
in reply to: AcadAdamLT

I thought you missed the idea first time round Smiley Wink yes it is a very long script, but it's worth the effort if you use it a lot.

Message 15 of 18
PatrickByrne
in reply to: steven-g

Great idea, once set up it would work quickly. We were looking at the idea of adding variables to our Batch program, I can see it been very useful in this situation. That way you would not have to change the Tag name in the script just change the variable value.

 

The one good thing is we can combine scripts at run time, this allows you to have the main script to blank the attribute value and a separate script routine to change the attribute value.

 

Once again great idea.

 

Patrick
http://www.multi-batch.com/

For your entire batch processing needs

Message 16 of 18
steven-g
in reply to: PatrickByrne

Thank you for the kind words Smiley Happy It's nice to know when an answer helps someone.

Message 17 of 18
gideon.botes
in reply to: steven-g

@steven-g

 

A thank you from me too!

 

I have been searching long and hard for a solution to the same problem as experienced by @AcadAdamLT with no answer. The problem is simply that Autodesk haven't provided for a wildcard in the 'change' and that with 'replace' you have to physically select each and every instance, rendering the idea of automation obsolete.

 

Nevertheless, your solution allows one to clear the attribute values in order to re-populate them.

 

I hope you don't mind, but I rewrote your script to use the lisp function "command" to write all parameters on a single line.

 

I hope this is not at the expense of performance, but it does improve readability and shorten the text file, so that maybe someone in the future can understand it better and improve upon it (if so, dear stranger, please share!).

 

Please find my iteration attached.

 

(Side note: I used capital letters as per convention in our company, and some special characters I feel are common. Please add/remove and experiment with more. I did however, find a problem with the backslash "\" special character. This one causes the script to malfunction - probably because it is itself, an escape character for Unicode values.)

(Second side note: Please use with care and always save your work before running a script).

Tags (3)
Message 18 of 18
PatrickByrne
in reply to: gideon.botes

Just a quick update, since you are now using AutoCAD full and lisp you could check out the Gatte command which is available in AutoCAD, this allows you to change attribute values without knowing the value beforehand.

Below is how to run it in a script file:

;Update all blocks of NAME/Attribute with same value. This will replace existing Attributed Text
;Change for your needs
gatte
b
;Block Name
Titleblock
;Atrribute Name to change
DRAWNDATE
;Text to change attribute to.
3/05/07
Y
_regen
_qsave


Sometimes you will have a job where the block name is in separate parts, for example Title Block instead of TitleBlock, this will stop routines written outside lisp, an easy workaround is to rename the block first, then run the change attributes routine and then you can rename the block back.

 

;;Rename a block. Can also be used to rename Dimstyle/LAyer/LType/Style/Ucs/VIew/VPort
;
_rename
_block
;old block name
Title Block
;;new block name
TitleBlock
_qsave

 


Patrick
http://www.multi-batch.com/

For your entire batch processing needs

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

Post to forums  

Autodesk Design & Make Report

”Boost