How to save the current draw and run etransit

How to save the current draw and run etransit

Anonymous
Not applicable
1,210 Views
12 Replies
Message 1 of 13

How to save the current draw and run etransit

Anonymous
Not applicable

Hello,

 

From my developer background I am trying to help one collegue, but I have no idea about autocad.

 

We are looking the way to do the following:

 

- run a routine which removes several layers (DONE)

- save the draw state after the routine is done as another temporal draw

- use this temporal draw to create a etransit file

 

I have been reading and analizing several scripts but I can't find the key to achieve it.

 

Any guide or help will be much appreaciate.

 

Regards.

0 Likes
Accepted solutions (1)
1,211 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
What I have tried is to declare this routine extracted from:
https://forums.autodesk.com/t5/autocad-2000-2000i-2002-archive/etransmit-via-script/td-p/1202902

;;Start of Routine

;; Get drawing Name
(setq draw_name(getvar "dwgname"))
;;
;; Remove extension
(setq filelen (- (strlen draw_name) 4)) (setq draw_name (substr draw_name 1 filelen))
;; ;;Add directory where name is going to be stored
(setq dir_name "c:\\test\\" )
(setq draw_name (strcat dir_name draw_name ))
(princ draw_name)
;; ;; Transmittal Message
(setq trans_mes "This is a test for etransmit")
;;
(command "-etransmit" "e" draw_name trans_mes "" "y" "n" "n" "y" "n" "")
;; ;;End of Routine Patrick http://www.multi-batch.com/ For your entire batch processing needs

But when I run, etransmit seems to is not taken the new filename and it ask for save the current draw.

OUTPUT:
Command: _appload ETRANSMIT.lsp successfully loaded.
Command: c:\test\R38 DES MP CAMINT 01-13-etransmit You must save changes before continuing with eTransmit. Save changes to R38 DES MP CAMINT 01-13.dwg? [Yes/No] <Yes>: e
Invalid option keyword.
; error: Function cancelled
You must save changes before continuing with eTransmit. Save changes to R38 DES MP CAMINT 01-13.dwg? [Yes/No] <Yes>:
0 Likes
Message 3 of 13

hmsilva
Mentor
Mentor

Try to add

(if (/= (getvar 'dbmod) 0)
    (command "_.qsave")
)

just before the

 

(command "-etransmit" "e" draw_name trans_mes "" "y" "n" "n" "y" "n" "")

Hope this helps,
Henrique

 

EESignature

0 Likes
Message 4 of 13

Anonymous
Not applicable

Hi, thanks so much. I have advanced one step more. The transmit file is created. Great.

 

By the way when the script finish and creates the new transmit file, the APPLOAD runs again and I can't see why. 

Could you point out the reason?

 

Here is the current result after the execution:

 

Command: _appload ETRANSMIT.lsp successfully loaded.
Command: _.qsave
Command: -etransmit
Updating fields...
8 field(s) found
8 field(s) updated
Enter an option [Create transmittal package/Report only/CUrrent setup/CHoose setup] <Report only>: c
Gathering files ...
File name for transmittal package: C:\Users\jvelasco\Desktop\R38 DES MP CAMINT 01-13
Transmittal created: C:\Users\jvelasco\Desktop\R38 DES MP CAMINT 01-13.zip.
Command: APPLOAD
Command: y Unknown command "Y". Press F1 for help.
Command: n Unknown command "N". Press F1 for help.
Command: n Unknown command "N". Press F1 for help.
Command: y Unknown command "Y". Press F1 for help.
Command: n Unknown command "N". Press F1 for help.
Command: APPLOAD

 

Here is the current state of the script:

 

;; Start of Routine

;; Get drawing Name
(setq draw_name(getvar "dwgname"))
;; Remove extension
(setq filelen (- (strlen draw_name) 4)) (setq draw_name (substr draw_name 1 filelen))
;;Add directory where name is going to be stored
(setq dir_name "C:\\Users\\jvelasco\\Desktop\\" )

 

(setq draw_name (strcat dir_name draw_name ))
(if (/= (getvar 'dbmod) 0)
(command "_.qsave")
)
(command "-etransmit" "c" draw_name "" "y" "n" "n" "y" "n" "")

 

 

From my little understanding after the Transmital created message everything might be fine and I don't know why is loading trying to load again a routine and which one.

 

I'll continue appreciating your help.

0 Likes
Message 5 of 13

Anonymous
Not applicable
Hi again, it seems the rest of options are not needed, by removing them the script finish and the transmitt file is created.

(command "-etransmit" "c" draw_name)

Do you think it could be a problem?
Thanks for your time!
0 Likes
Message 6 of 13

hmsilva
Mentor
Mentor

@Anonymous wrote:
Hi again, it seems the rest of options are not needed, by removing them the script finish and the transmitt file is created.

(command "-etransmit" "c" draw_name)

Do you think it could be a problem?
Thanks for your time!

Hi JMVelascoMartinez,

Sorry, but I don't have AutoCAD in this laptop, to test the previous code (message #4)...

Edit:I had not read correctly the code from msg #4, you did replace the option to "_C", and  with the 'Create transmittal package' option, we only need to give the package name, so the

(command "-etransmit" "c" draw_name)

it's correct.

 

Henrique

EESignature

0 Likes
Message 7 of 13

Anonymous
Not applicable
Hi Henrique, thanks so like it is now should be fine.

Thanks.
0 Likes
Message 8 of 13

Anonymous
Not applicable

Hello Henrique,

 

The problem we are facing on now is the original draw is being saved and I need to keep the original draw. 

Is that possible? 

 

I will continue testing but if you can give me the hint I will much appreciate. From you or whoever other reader.

 

I paste my current script:

 

(defun c:ELAYER (/ aDoc name)
(setvar 'Clayer "0")
(repeat 4
(vla-purgeall
(setq aDoc (vla-get-ActiveDocument
(vlax-get-acad-object)))))
(vlax-for
itm
(vla-get-layers aDoc)
(if (and
(not (wcmatch
(setq name (vla-get-name itm))
"*|*"))
(not (eq name "0"))
(member name
'(
"LAYER01"
"LAYER02"
"LAYER03"
"LAYER04"
)
)
)
(progn
(vla-put-lock itm :vlax-false)
(vl-cmdf "_.-laydel" "_N" name "" "_Y"))
)
)
(repeat 4 (vla-purgeall aDoc))
(princ)

(setq draw_name(getvar "dwgname"))
;; Remove extension from the drawing Name
(setq filelen (- (strlen draw_name) 4))
(setq draw_name (substr draw_name 1 filelen))
;; Add directory where name is going to be stored
(setq dir_name "C:\\Users\\jvelasco\\TEMP\\" )
;; Set the target name for the transmit package
(setq draw_name (strcat dir_name draw_name ))
;; Do the transmit package
(if (/= (getvar 'dbmod) 0)
(command "_.qsave")
)
(command "-etransmit" "c" draw_name)
)

 

Thanks for your time.

0 Likes
Message 9 of 13

hmsilva
Mentor
Mentor
Accepted solution

Untested...

 

(defun c:ELAYER (/ aDoc name)
    (command "_.undo" "_G")
    (setvar 'Clayer "0")
    (repeat 4
        (vla-purgeall
            (setq aDoc (vla-get-ActiveDocument
                           (vlax-get-acad-object)
                       )
            )
        )
    )
    (vlax-for
              itm
                 (vla-get-layers aDoc)
        (if (and
                (not (wcmatch
                         (setq name (vla-get-name itm))
                         "*|*"
                     )
                )
                (not (eq name "0"))
                (member name
                        '(
                          "LAYER01"
                          "LAYER02"
                          "LAYER03"
                          "LAYER04"
                         )
                )
            )
            (progn
                (vla-put-lock itm :vlax-false)
                (vl-cmdf "_.-laydel" "_N" name "" "_Y")
            )
        )
    )
    (repeat 4 (vla-purgeall aDoc))
    (setq draw_name (getvar "dwgname"))
    ;; Remove extension from the drawing Name
    (setq filelen (- (strlen draw_name) 4))
    (setq draw_name (substr draw_name 1 filelen))
    ;; Add directory where name is going to be stored
    (setq dir_name "C:\\Users\\jvelasco\\TEMP\\")
    ;; Set the target name for the transmit package
    (setq draw_name (strcat dir_name draw_name))
    ;; Do the transmit package
    (if (/= (getvar 'dbmod) 0)
        (command "_.qsave")
    )
    (command "-etransmit" "c" draw_name)
    (command "_.undo" "_E")
    (command "_.undo" "")
    (command "_.qsave")
    (princ)
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 10 of 13

Anonymous
Not applicable

Hi, thanks so much. I am going to try your code. By the way I think to achieved it also like this:

 

(defun c:ELAYER (/ aDoc name)
(setq draw_name(getvar "dwgname"))
(setq dir_name "C:\\Users\\jvelasco\\TRANSMIT_FILES\\" )
(setq draw_name (strcat dir_name "R_" draw_name))
(vla-SaveAs (vla-get-ActiveDocument(vlax-get-acad-object)) draw_name acNative)

(setvar 'Clayer "0")
(repeat 4
(vla-purgeall
(setq aDoc (vla-get-ActiveDocument
(vlax-get-acad-object)))))
(vlax-for
itm
(vla-get-layers aDoc)
(if (and
(not (wcmatch
(setq name (vla-get-name itm))
"*|*"))
(not (eq name "0"))
(member name
'(
"X layer1"
"X layer2"
"X layer3"
"X layer4"
)
)
)
(progn
(vla-put-lock itm :vlax-false)
(vl-cmdf "_.-laydel" "_N" name "" "_Y"))
)
)
(repeat 4 (vla-purgeall aDoc))
(princ)
;; Remove extension from the drawing Name
(setq filelen (- (strlen draw_name) 4)) 
(setq draw_name (substr draw_name 1 filelen))
;; Set the target name for the transmit package
(setq draw_name (strcat dir_name draw_name ))
;; Do the transmit package
(if (/= (getvar 'dbmod) 0)
(command "_.qsave")
)
(command "-etransmit" "c" draw_name)
)

Do you think I am doing things wrong like this?

If your script works I will probably use your approach but I am looking to understand as well even if this is not my field.

 

Thank you so much again.

 

0 Likes
Message 11 of 13

hmsilva
Mentor
Mentor

Both approaches should work as expected, mine will use the original file, and restore the original state at code end, your's will create a new dwg file, and and modifies it...

 

Henrique

EESignature

0 Likes
Message 12 of 13

Anonymous
Not applicable

Hi again, yes I was thinking on this, so your approach seems better to me since there is no need to create an extra file.

 

Thank you very much for your time. You have helped a lot myself.

0 Likes
Message 13 of 13

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hi again, yes I was thinking on this, so your approach seems better to me since there is no need to create an extra file.

 

Thank you very much for your time. You have helped a lot myself.


You're welcome, JMVelascoMartinez
Glad I could help

Henrique

EESignature

0 Likes