ATTIN with a pre specified filename (Lisp)

ATTIN with a pre specified filename (Lisp)

Mike_Y2
Advocate Advocate
666 Views
9 Replies
Message 1 of 10

ATTIN with a pre specified filename (Lisp)

Mike_Y2
Advocate
Advocate

Hi,

 

I am looking for a lisp file that will use the run the ATTIN command but does NOT ask the user for the filename. The file name will always be "C:\Panel No UPDATE\3 ATTIN Import.txt" and therefore it can be hard coded into the lisp.

 

I have found lots of posts on this subject but, they are all trying to do additional tasks and I can't work out how to separate the code 😞

 

Thanks in advance for your help

Mike

0 Likes
Accepted solutions (1)
667 Views
9 Replies
Replies (9)
Message 2 of 10

Mike_Y2
Advocate
Advocate

Sorry forgot to mention that after using ATTIN you need to use the REGEN commend to update Blocks that contain "fields" that are linked to an Attribute value. Therefore if could the REGEN be added at the end of the above Lisp code?

0 Likes
Message 3 of 10

paullimapa
Mentor
Mentor
Accepted solution

**Modified**

Try this code. Save as Att-in.lsp and then on AutoCAD command line enter:

(load”att-in”)

or drag+drop saved Att-in.lsp onto AutoCAD drawing area and then to run enter: Att-in

 

; att-in runs attin with predefined filename
; modified from:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-and-attin-to-file-by-lisp/m-p/3649704#M306885
(defun  c:att-in (/ cmdecho tmpn)
  (load "attout")
  (setq cmdecho (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (setq #bns_attin_modified 0)
  (if (setq
        tmpn
         (findfile
         "C:\\Panel No UPDATE\\3 ATTIN Import.txt" 
         )
      )
    (progn
     (bns_attin tmpn nil)
     (command "_.Regen")
    ) ; progn
 ) ; if
(setvar"cmdecho"cmdecho)
(princ)
) ; defun

 

 

 

 

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 10

Mike_Y2
Advocate
Advocate

@paullimapa 

Thanks for the quick reply. When I run the command I get an error as below. Any ideas how to fix this???

 

Command: ATT-IN
; error: bad argument type: (or stringp symbolp): nil
Command:

0 Likes
Message 5 of 10

EnM4st3r
Advocate
Advocate
in line 6 the apostrophe on cmdecho is wrong.

change ‘cmdecho to 'cmdecho
Message 6 of 10

Mike_Y2
Advocate
Advocate

@EnM4st3r 

 

I now get a different error...

 

; error: no function definition: BNS_ATTIN

0 Likes
Message 7 of 10

paullimapa
Mentor
Mentor

change line:

(if(not c:attout)(load "attout"))

to:

(load "attout")

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 10

paullimapa
Mentor
Mentor

just saw another quote symbol error with Regen line in code...I've made all the corrections in the OP....go back to that and save...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 10

Mike_Y2
Advocate
Advocate

@paullimapa Thanks Paul your revised code works I will mark it as the answer

0 Likes
Message 10 of 10

paullimapa
Mentor
Mentor

Glad that finally worked out for you…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes