Small Fish Posted November 11, 2009 Posted November 11, 2009 hi I am trying to write some code that applies the ATTIN command across all tabs in a drawing. It cycles through the tabs but I can not seem to make the path (TextFile) work with ATTIN command. Any ideas what needs to change? Thanks (defun c:UberGatte(/ TextFile OldFld LayList) (setq OldFld (getvar "filedia")) (setvar "filedia" 0) (setq TextFile(dos_getfiled "Select a Text file for global attributes edit" "C:\\Documents and Settings\\rxbeeto0\\Temp\\" "Text files (*.txt)|*.txt|All files (*.*)|*.*||")) (setq LayList (layoutlist)) (foreach Ln LayList (setvar "CTAB" Ln) (command "ATTIN" TextFile ) );foreach (setvar "filedia" OldFld) (princ) );defun Quote
BIGAL Posted November 12, 2009 Posted November 12, 2009 I can not find info on ATTIN ? but I think I know the answer to your problem C:\\Documents and Settings Once the directory path has a space in it the file name stops try a new path without spaces (underscores etc are ok). I had to use a bit of vba code within lisps to get round this problem. If Autodesk is listening it may be a bug in the software. Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 Attin is an Express Tools' Lisp Routine. I cannot be called with (command "attin") Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 I can not find info on ATTIN ? but I think I know the answer to your problem C:\\Documents and Settings Once the directory path has a space in it the file name stops try a new path without spaces (underscores etc are ok). I had to use a bit of vba code within lisps to get round this problem. If Autodesk is listening it may be a bug in the software. Really? I've never experienced that problem. Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 BigAl Thanks No - that does not work. eg I tried C:\\Temp\\ and I still have the same problem. There is info regarding ATTIN command. You need to go to express tools and then HELP. As ATTIN is not compiled I could edit the file but I am not really sure how to. Perhaps someone could help me? Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 Hi Alanjt - So if I can not use (command "ATTIN" .... then what do I use? Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 Hi Alanjt - So if I can not use (command "ATTIN" ....then what do I use? Have to do a little research and get a little creative: Completely untested, since I know nothing about AttIn. (defun c:UberGatte (/ TextFile) (and (or bns_attin (load (findfile "attout.lsp") nil)) (setq TextFile (getfiled "Select a Text file for global attributes edit" "C:\\Documents and Settings\\rxbeeto0\\Temp\\" "txt;*" 8 ) ;_ getfiled ) ;_ setq (foreach Ln (layoutlist) (setvar "CTAB" Ln) (if (equal 4 (logand 4 (getvar "cmdactive"))) (bns_attin TextFile nil) ;a script is running so no interactive placement (bns_attin TextFile T) ;Allow interactive placement ) ;_ if ) ;_ foreach ) ;_ and (princ) ) ;_ defun I hope you don't mind, I did a little reworking on your code. BTW, you can use getfiled when only needing to select 1 file and avoid relying on dos_lib. Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 Thanks! Alan you are pure genius!! Just wondering what the function bns_attin does and how it does work? Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 Thanks! Alan you are pure genius!!Just wondering what the function bns_attin does and how it does work? It's just the subroutine that performs all the functions that AttIn facilitates. Did it work? Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 I updated the code to check for existence/load AttOut.lsp before file selection. That way, it will exit if it can't find the file. Sorry, wasn't thinking clearly. Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 Alan yes it works, although I will need to polish it up and make it more automated - get rid off annoying alert messages and selection of block for every tab. However the immediate problem now is when I try it, I get in the command line for every tab: Reading the input file... Done._.UNDO Current settings: Auto = Off, Control = All, Combine = Yes Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: _BEGIN Command: _.UNDO Current settings: Auto = Off, Control = All, Combine = Yes Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: _END Command: Regenerating layout. I tried turning UNDO off but that does work. Not sure what that's about? Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 Alan yes it works, although I will need to polish it up and make it more automated - get rid off annoying alert messages and selection of block for every tab. However the immediate problem now is when I try it, I get in the command line for every tab: Reading the input file... Done._.UNDO Current settings: Auto = Off, Control = All, Combine = Yes Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: _BEGIN Command: _.UNDO Current settings: Auto = Off, Control = All, Combine = Yes Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back] <1>: _END Command: Regenerating layout. I tried turning UNDO off but that does work. Not sure what that's about? Well, keep me posted. Try (setvar 'cmdecho 0) Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 I think its probably the (acet-undo-end) and (acet-undo-begin) express tools functions within bns_attin interfering, with my code. I think I may have to do a 'save as' on ATTIN and edit to suit what I am trying to do. Tomorrow I will look at it again, although the attin code is hard to understand....... Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 Okay here is what I have now. It works though not tested thoroughly. If used on title blocks it's important to delete columns that don't need to be changed otherwise all attributes(eg dwg number) on different tabs will end up with the same value. Additionally the handle value also needs to be deleted from the text file otherwise it does not work. Press 'Escape' to cancel and 'Enter' to skip tab. Please try to improve it, if you have any ideas -thanks cheers S.F. UberGatte.lsp Quote
alanjt Posted November 12, 2009 Posted November 12, 2009 Okay here is what I have now. It works though not tested thoroughly.If used on title blocks it's important to delete columns that don't need to be changed otherwise all attributes(eg dwg number) on different tabs will end up with the same value. Additionally the handle value also needs to be deleted from the text file otherwise it does not work. Press 'Escape' to cancel and 'Enter' to skip tab. Please try to improve it, if you have any ideas -thanks cheers UberGatte.lsp I'll look at it when I get home (after dinner and my little girl goes to sleep). Post me an example DWG and txt file, so I can actually see what it does. Quote
Small Fish Posted November 12, 2009 Author Posted November 12, 2009 Okay try this. Attached is a sample dwg and text file. Its probably better to edit it as a csv file rather than just a text file so that it keeps some of its format. Sample.dwg Sample.txt Quote
Recommended Posts
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.