Hello,
How to create a lisp to automatically export attributes from selected blocks to defined txt file without having to everytime confirm the file name, location and if the file shall be replaced?
Meaning is that I often export attributes to txt file for further use. It is always the same file (I just overwrite it always).
The way I do it now is selecting blocks, using ATTOUT command, then going to the desktop, selecting ATT.txt file and confirming that it is to be replaced.
Is there a way to make lisp or script that will just do all it in at once?
I found on forum such a lisp as below, but it exports all ablocks on drawing and it exports to txt file which is located in same place as drawing and with same name as drawing. Tried to modify it but without success:
(defun c:out-att ()
(load "attout")
(setq fna (strcat (getvar "dwgprefix")
(acet-filename-path-remove (acet-filename-ext-remove (getvar "dwgname")))
".txt"
))
(setq ss (ssget "X" '((0 . "INSERT") (66 . 1))))
(bns_attout fna ss)
)
Same question for ATTIN - I use attin and always same file name from same location - how to automate it with one command?
miroko
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
@miroko wrote:...
I found on forum such a lisp as below, but it exports all ablocks on drawing and it exports to txt file which is located in same place as drawing and with same name as drawing. Tried to modify it but without success:
miroko
what part of the code you want to modify?
The name of the target file?
replace this...
(strcat (getvar "dwgprefix") (acet-filename-path-remove (acet-filename-ext-remove (getvar "dwgname"))) ".txt")
with
(yourpathandfilename) e.g. "C:\\Users\\MyLogin\\Desktop\\today.txt"
Block selection? For you to be able to select from screen
Take out "X" from
(setq ss (ssget "X" '((0 . "INSERT") (66 . 1))))
to
(setq ss (ssget '((0 . "INSERT") (66 . 1))))
HTH
Hello
Thank you for help.
Sorry for not being specific enough.
I would like to do following.
1 Manually select blocks which i want to be exported (not selecting during lisp is active)
2 Run the lisp which will export attributes from already selected blocks to predefined file:
"C:\Documents and Settings\username\Desktop\att.txt "
After your reply i have following code:
(defun c:att-out ()
(load "attout")
(setq fna "C:\\Documents and Settings\\username\\Desktop\\att.txt")
(setq ss (ssget '((0 . "INSERT") (66 . 1))))
(bns_attout fna ss)
)
It is working (needed to remove brackets from around the path).
Thank you for help.
Could you also see on hiow it should look like when i want to import attributes from same file by lisp?
miroko
@miroko wrote:
Could you also see on hiow it should look like when i want to import attributes from same file by lisp?
miroko
(defun c:att-in (/ fna) (load "attout") (if (setq fna (findfile "C:\\Documents and Settings\\username\\Desktop\\att.txt")) (bns_attin fna nil) ) )
HTH
@pbejse wrote:
@miroko wrote:
Could you also see on hiow it should look like when i want to import attributes from same file by lisp?
miroko
(defun c:att-in (/ fna) (load "attout") (if (setq fna (findfile "C:\\Documents and Settings\\username\\Desktop\\att.txt")) (bns_attin fna nil) ) )
HTH
Hello
thanks for your time.
unfortunatelly this one is returning error:
--
Reading the input file... Done.; error: bad argument type: numberp: nil
--
I just exported the attributes and without any changes tried to import back and error appeared (i did not edit the create file).
For info: 'number' from error is name of one of attributes, but name of attribute is without 'p;' as it says in error 'numberp:'
Cannot see what can be wrong.
Tried first with edited txt file and thought that i edited it wrong but without editing it also not work.
Could you see once more?
miroko
@miroko wrote:
thanks for your time.
unfortunatelly this one is returning error:
--
Reading the input file... Done.; error: bad argument type: numberp: nil
--
I just exported the attributes and without any changes tried to import back and error appeared (i did not edit the create file).
For info: 'number' from error is name of one of attributes, but name of attribute is without 'p;' as it says in error 'numberp:'
.....
miroko
Try this
(defun c:att-in (/ tmpn) (load "attout") (setq #bns_attin_modified 0) (if (setq tmpn (findfile "C:\\Documents and Settings\\username\\Desktop\\att.txt" ) ) (bns_attin tmpn nil) ) )
The numberp error has nothing to do with your attribute name. 🙂
Hello
Now it is working, thanks!
Could you say what the lisp is doing? I noticed that there is lot of 'undo':
------------------
Reading the input file... Done._.UNDO Current settings: Auto = On, Control =
All, Combine = Yes, Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: _BEGIN
Command: _.UNDO Current settings: Auto = On, Control = All, Combine = Yes,
Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: _END
Command: _.UNDO Current settings: Auto = On, Control = All, Combine = Yes,
Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: _BEGIN
Command: _.UNDO Current settings: Auto = On, Control = All, Combine = Yes,
Layer = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: _END
--------------------
Just curious why it is like that.
But anyway thank you fo help!
@pbejse wrote:
Try this
(defun c:att-in (/ tmpn) (load "attout") (setq #bns_attin_modified 0) (if (setq tmpn (findfile "C:\\Documents and Settings\\username\\Desktop\\att.txt" ) ) (bns_attin tmpn nil) ) )
The numberp error has nothing to do with your attribute name. 🙂
miroko
@miroko wrote:Hello
Now it is working, thanks!
Could you say what the lisp is doing? I noticed that there is lot of 'undo':....
Just curious why it is like that.
But anyway thank you fo help!
miroko
You are welcome, Glad it works for you.
It is generated by the ET attouts' error sub program which i did not really spend time pondering on it. 🙂
If it bothers you, you can set cmdecho to 0 to "prevent" those from printing on the command prompt
like this
(defun c:att-in (/ tmpn) (load "attout") (setvar 'cmdecho 0) (setq #bns_attin_modified 0) (if (setq tmpn (findfile "C:\\Documents and Settings\\username\\Desktop\\att.txt" ) ) (bns_attin tmpn nil) ) )
HTH
hello
thanks
and how to turn the cmdecho back inside this lisp?
I tried to put somewhere in end same command but with 1 instead of 0 but it does not want to work
miroko
@pbejse wrote:
@miroko wrote:Hello
Now it is working, thanks!
Could you say what the lisp is doing? I noticed that there is lot of 'undo':....
Just curious why it is like that.
But anyway thank you fo help!
miroko
You are welcome, Glad it works for you.
It is generated by the ET attouts' error sub program which i did not really spend time pondering on it. 🙂
If it bothers you, you can set cmdecho to 0 to "prevent" those from printing on the command prompt
like this
(defun c:att-in (/ tmpn) (load "attout") (setvar 'cmdecho 0) (setq #bns_attin_modified 0) (if (setq tmpn (findfile "C:\\Documents and Settings\\username\\Desktop\\att.txt" ) ) (bns_attin tmpn nil) ) )
HTH
Hi miroko,
Here's how I do it in my programs:
;;;At the Beginning of program: ;;;Save and Change AutoCAD Variables (setq CE-SAVE (getvar "cmdecho")) ;;;Change AutoCAD variables (setvar "cmdecho" 0) ;;;At the end of program: ;;Return Variables to original state (setvar "cmdecho" CE-SAVE)
@AR12 wrote:Hi miroko,
Here's how I do it in my programs:
;;;At the Beginning of program: ;;;Save and Change AutoCAD Variables (setq CE-SAVE (getvar "cmdecho")) ;;;Change AutoCAD variables (setvar "cmdecho" 0) ;;;At the end of program: ;;Return Variables to original state (setvar "cmdecho" CE-SAVE)
Hi AR12,
It is working fine.
Thank you.
regards
miroko
i m using attout to extract blocks within blocks but it is not coming , is this possible
PLEASE reply....
@chestanu435 wrote:
i m using attout to extract blocks within blocks but it is not coming , is this possible
PLEASE reply....
Can you be more specific chestanu435?
Hi guys!
I have a question about this discussion, I don't want to create a new for this...
So, I'm try to create a LSP and/or scr to do ATTOUT in multiple files, whatever it is opened or by folder. Using the lsp that I found here, the dialog of ATTOUT appears, but with this it's impossible to create anything.
I'm using AutoCAD 2016.
Anyone know what can I do?
Thanks!
Hi,
I'm new to AutoLisp..
Can you explain how can i use this .lsp function in a script file (.scr)???
I'm trying to automise the ATTOUT operation in Java but i don't know how 😞
Many thanks!!
Stop cross posting new questions on old threads. Stop duplicating your threads! Wait till the conversation develops.
sorry sir, can you help me how i can modify that Att-out automatice export atribute with specific name, ex:TB-ASBUILTSHOPDWG, or TB 1.
I want use that lisp on script so i can export title drawing on all my drawing. thank you
I also want to automate my ATTOUT, but without success,
What's wrong?
(defun c:MyAttout (/ tmpn)
(load "attout")
(setvar 'cmdecho 0)
(setq #bns_attin_modified 0)
(if (setq
tmpn
(findfile
"D:\soft\att.txt"
)
)
(bns_attin tmpn nil)
)
)