lisp etransmit - all open file

lisp etransmit - all open file

dvir860
Enthusiast Enthusiast
3,765 Views
10 Replies
Message 1 of 11

lisp etransmit - all open file

dvir860
Enthusiast
Enthusiast

I have a lisp that makes save, zip, close the file.
Is there a possibility that it will Lisp but will work on all open files Autocad (the same principle of commands closeall and saveall)?

 

 

 

The lisp:

 

(DEFUN c:etra ()

(command "_qsave")

(command "_etransmit"

"_c"

(strcat (getvar "dwgprefix")

(substr (getvar "dwgname")

1

(- (strlen (getvar "dwgname")) 3)

)

"ZIP"

)

)

(command "_close")

)

(etra)

0 Likes
Accepted solutions (2)
3,766 Views
10 Replies
Replies (10)
Message 2 of 11

Satoews
Advocate
Advocate

I told myself I would only work on this for around 20 min, 2 hours later. . . Smiley Very Happy

 

This works for me so hopefully it works for you too.

 

(DEFUN C:TRYTHIS ( / no MyOpen FileName fileNumber folderStuff)

  (VL-LOAD-COM)
  
  (defun MyOpen ( / ) ;; If readonly is not nil, then it will open the file as read-only.
    (vla-Open
     (vla-get-Documents
     (vlax-get-Acad-Object))
       FileName
       (if ReadOnly
       :vlax-true
       :vlax-false
       )
    )
  ) 
  
  (SETQ fileNumber (getstring "\nEnter folder to open."))
  (setq folderStuff (vl-directory-files  (strcat (getvar "dwgprefix") fileNumber)))
  (setq no 0)
    (repeat (vl-list-length folderStuff)
    (if (wcmatch (nth no folderStuff) "*.dwg")
      (progn
        (setq fileName (strcat (getvar "dwgprefix") fileNumber "\\" (nth no folderstuff)))
		(myopen)))
      (setq no (1+ no)))


  
)

Where I Copied MyOpen from post 5

Shawn T
0 Likes
Message 3 of 11

dvir860
Enthusiast
Enthusiast

Hi Tornac,
Thanks for the help.
Somehow the result that I wish did not work.
When I run the lisp you have written, I have not performed the order of the commands I want.
I want to be performed ETRANSMIT (including save beginning and closing the file at the end) all open files of AutoCAD by Lisp file one.

Is there a command that tells AutoCAD to make the lisp all open files?

 

Dvir

0 Likes
Message 4 of 11

hmsilva
Mentor
Mentor
Accepted solution

@dvir860 wrote:

I have a lisp that makes save, zip, close the file.
Is there a possibility that it will Lisp but will work on all open files Autocad (the same principle of commands closeall and saveall)?

 

 

 

The lisp:

 

(DEFUN c:etra ()

(command "_qsave")

(command "_etransmit"

"_c"

(strcat (getvar "dwgprefix")

(substr (getvar "dwgname")

1

(- (strlen (getvar "dwgname")) 3)

)

"ZIP"

)

)

(command "_close")

)

(etra)


Hello dvir860,

I would suggest to use a '*.scr' file to call your 'etra'...

 

You'll have to change your code, the (etra) will not call your function...

Change (etra) to (c:etra)

 

Quick and dirty...

(vl-load-com)
(defun c:demo (/ acadobj adoc dwglst ofile scrfile)
   (c:saveall)
   (setq acadobj (vlax-get-acad-object)
         adoc    (vla-get-activedocument acadobj)
   )
   (vlax-for doc (vla-get-documents acadobj)
      (if (not (equal adoc doc))
         (progn
            (setq dwglst (cons (vla-get-fullname doc) dwglst))
            (vla-close doc)
         )
      )
   )
   (setq scrfile (strcat (getenv "Temp") "\\My_Script.scr")
         ofile   (open scrfile "w")
   )
   (foreach dwg dwglst
      (write-line (strcat "_.open\r" (chr 34) dwg (chr 34) "\r") ofile)
      (write-line
         (strcat "(load " (chr 34) "c:/your/path/etra.lsp" (chr 34) ")\r")
         ofile
      )
   )
   (close ofile)
   (command "_.script" scrfile)
   (vla-sendcommand adoc (strcat "(load " (chr 34) "c:/your/path/etra.lsp" (chr 34) ")\r"))
)

Change the "c:/your/path/etra.lsp" to the correct path...

 

 

Hope this helps,
Henrique

 

EESignature

Message 5 of 11

dvir860
Enthusiast
Enthusiast

Hello Henrique,

After I perform the steps you wrote, and I run the demo.lsp, the AutoCAD shows me a message: "error writing / closing file".
 
 
And On the command line:
Command: DEMO
Initializing...Loading AEC Core...
Automation Error. Error saving the document
 
 
What could be the problem?
 
 
Dvir.
 
0 Likes
Message 6 of 11

hmsilva
Mentor
Mentor

@dvir860 wrote:

Hello Henrique,

After I perform the steps you wrote, and I run the demo.lsp, the AutoCAD shows me a message: "error writing / closing file".
 
 
And On the command line:
Command: DEMO
Initializing...Loading AEC Core...
Automation Error. Error saving the document
 
 
What could be the problem?
 
 
Dvir.
 

Hi dvir860,

I did test the 'demo' in AutoCAD 2010, without any error.

Are you using 'vanilla' AutoCAD?

 

Henrique

EESignature

0 Likes
Message 7 of 11

dvir860
Enthusiast
Enthusiast

I tried the Lisp on 'vanila' AutoCAD and also AutoCAD Architecture

0 Likes
Message 8 of 11

dvir860
Enthusiast
Enthusiast

Can you attach files you work?

0 Likes
Message 9 of 11

hmsilva
Mentor
Mentor

@dvir860 wrote:

I tried the Lisp on 'vanila' AutoCAD and also AutoCAD Architecture


Tested in AC2014, and I did get a fatal error... 😞

Tonight at home, I'll try to find what is causing the error.

 

Henrique

EESignature

0 Likes
Message 10 of 11

dvir860
Enthusiast
Enthusiast

hi Henrique,

 

Thank you!
I was able to make the lisp.

The error was probably my mistake my performance steps you have written.
Again, thank you very much for your help!

 

Dvir.

0 Likes
Message 11 of 11

hmsilva
Mentor
Mentor
Accepted solution

@dvir860 wrote:

hi Henrique,

 

Thank you!
I was able to make the lisp.

The error was probably my mistake my performance steps you have written.
Again, thank you very much for your help!

 

Dvir.


You're welcome, Dvir.
Glad you have it sorted!

Henrique

EESignature

0 Likes