Author Topic: Download with vlisp  (Read 12260 times)

0 Members and 1 Guest are viewing this topic.

Patrick_35

  • Guest
Download with vlisp
« on: February 23, 2007, 05:22:11 AM »
Hello,

How download a link without Dialog Box and without use SendKey ?

I try
Code: [Select]
(setq shell (vlax-create-object "Shell.Application"))
(vlax-invoke shell 'open "http://carnet-de-cablage.chez-alice.fr/Lisp/Rbloc.zip")
(vlax-release-object shell)

And
Code: [Select]
(setq ie (vlax-Create-Object "InternetExplorer.Application"))
(vlax-invoke ie 'navigate "http://carnet-de-cablage.chez-alice.fr/Lisp/Rbloc.zip")
(vlax-release-object ie)

but i have the dialog box  :-(

Thanks

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Download with vlisp
« Reply #1 on: February 23, 2007, 09:37:03 AM »

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Re: Download with vlisp
« Reply #2 on: February 23, 2007, 09:42:11 AM »
What about ``GetRemoteFile''.

GetRemoteFile URL, LocalFile, IgnoreCache
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Patrick_35

  • Guest
Re: Download with vlisp
« Reply #3 on: February 23, 2007, 10:46:52 AM »
Excel ElpanovEvgeniy: -)
I thus arrive at well translating into vlisp, but how to write the response into binary  :?

Code: [Select]
'Create local file and save results to it
    vFF = FreeFile
    If Dir(vLocalFile) <> "" Then Kill vLocalFile
    Open vLocalFile For Binary As #vFF
    Put #vFF, , oResp
    Close #vFF

Se7en, I will make a research with regard to ``GetRemoteFile''.

Thank you with you two  :-)

@+

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Download with vlisp
« Reply #4 on: February 23, 2007, 11:49:23 AM »
This used to work ...

Code: [Select]
(defun mst-activate (/ key)
  (setq key (MST-GetFileFromURL
      "http://www.theswamp.org/lilly.pond/public/key.txt"
      )
)
  (if key
    (alert
      (strcat
"Thank you for being my beta tester\n Make note of this number -> "
key
)
      )
    )
  (princ)
  )


(defun MST-GetFileFromURL (strURL / fo key vlUtilObj RemoteFile TmpFile)
  (setq vlUtilObj (vla-get-Utility
    (vla-get-ActiveDocument (vlax-get-acad-object))
    )
)
  (if (and (= (type strURL) 'STR)
   (= (vla-IsURL vlUtilObj strURL) :vlax-true)
   )
    (setq RemoteFile
   (vl-catch-all-apply
     'vlax-invoke-method
     (list vlUtilObj 'GetRemoteFile strURL 'TmpFile :vlax-false)
     )
  )
    ) ; if
  (if (not (vl-catch-all-error-p RemoteFile))
    (if (setq fo (open TmpFile "r"))
      (if (setq key (read-line fo))
(close fo)
)
      )
    )
  (if (vl-file-delete TmpFile)
    key
    )
  )
(mst-activate)
TheSwamp.org  (serving the CAD community since 2003)

Patrick_35

  • Guest
Re: Download with vlisp
« Reply #5 on: February 26, 2007, 03:46:05 AM »
Great Mark

Thank you very much  :-)

@+

Patrick_35

  • Guest
Re: Download with vlisp
« Reply #6 on: February 26, 2007, 05:55:26 AM »
For the pleasure, and in spite of the great solution of Mark, I continued with the ElpanovEvgeniy proposal but a problem arises. How to write in a file the character Null (chr 0) ?

Thanks in advance

@+

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Download with vlisp
« Reply #7 on: February 26, 2007, 06:34:20 AM »
For the pleasure, and in spite of the great solution of Mark, I continued with the ElpanovEvgeniy proposal but a problem arises. How to write in a file the character Null (chr 0) ?

Thanks in advance

@+

Hi Patrick_35 :-)
This code writes to a file of 100 lines on 8 (chr 0)

Code: [Select]
(setq f(open "d:\\test.txt" "w"))
(repeat 100
 (WRITE-LINE (VL-LIST->STRING '(0 0 0 0 0 0 0 0)) f)
 )
(close f)
« Last Edit: February 26, 2007, 06:37:36 AM by ElpanovEvgeniy »

Patrick_35

  • Guest
Re: Download with vlisp
« Reply #8 on: February 26, 2007, 08:10:20 AM »
Thank you Evgeniy  :-)
I'm there almost what I don't understand, this is why when I open the zip and that I look at the files, those are empty  :?

Code: [Select]
(defun download (url dir / byte fic file http tbl)
  (setq http (vlax-create-object "MSXML2.XMLHTTP"))
  (vlax-invoke-method http 'open "get" url :vlax-false)
  (vlax-invoke http 'send)
  (while (not (eq (vlax-get http 'readyState) 4))
    (repeat 100)
  )
  (setq file (strcat dir (vl-filename-base url) (vl-filename-extension url))
tbl  (vlax-safearray->list (vlax-variant-value (vlax-get-property http 'responsebody)))
fic  (open file "w") n 0)
  (foreach byte tbl
    (if (eq byte 0)
      (princ (vl-list->string '(0)) fic)
      (write-char byte fic)
    )
  )
  (close fic)
  (vlax-release-object http)
  (princ)
)

Code: [Select]
(download "http://carnet-de-cablage.chez-alice.fr/Lisp/Latt.zip" "c:/")
@+

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Download with vlisp
« Reply #9 on: February 26, 2007, 08:43:47 AM »
Thank you Evgeniy  :-)
I'm there almost what I don't understand, this is why when I open the zip and that I look at the files, those are empty  :?

Code: [Select]
(defun download (url dir / byte fic file http tbl)
  (setq http (vlax-create-object "MSXML2.XMLHTTP"))
  (vlax-invoke-method http 'open "get" url :vlax-false)
  (vlax-invoke http 'send)
  (while (not (eq (vlax-get http 'readyState) 4))
    (repeat 100)
  )
  (setq file (strcat dir (vl-filename-base url) (vl-filename-extension url))
tbl  (vlax-safearray->list (vlax-variant-value (vlax-get-property http 'responsebody)))
fic  (open file "w") n 0)
  (foreach byte tbl
    (if (eq byte 0)
      (princ (vl-list->string '(0)) fic)
      (write-char byte fic)
    )
  )
  (close fic)
  (vlax-release-object http)
  (princ)
)

Code: [Select]
(download "http://carnet-de-cablage.chez-alice.fr/Lisp/Latt.zip" "c:/")
@+

Hello Patrick.
On my computer, this code works! :)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Download with vlisp
« Reply #10 on: February 26, 2007, 09:31:28 AM »
  (while (not (eq (vlax-get http 'readyState) 4))
    (repeat 100)
  )

If express established, such variant will load less processor...

Code: [Select]
(while (not (eq (vlax-get http 'readyState) 4))
   (if acet-sys-sleep
     (acet-sys-sleep 5);;(acet-sys-sleep [time-pause-msec])
    (repeat 100)
    )
  )

Patrick_35

  • Guest
Re: Download with vlisp
« Reply #11 on: February 26, 2007, 10:17:06 AM »
Thank you Evgeniy  :-)
I'm there almost what I don't understand, this is why when I open the zip and that I look at the files, those are empty  :?

Code: [Select]
(defun download (url dir / byte fic file http tbl)
  (setq http (vlax-create-object "MSXML2.XMLHTTP"))
  (vlax-invoke-method http 'open "get" url :vlax-false)
  (vlax-invoke http 'send)
  (while (not (eq (vlax-get http 'readyState) 4))
    (repeat 100)
  )
  (setq file (strcat dir (vl-filename-base url) (vl-filename-extension url))
tbl  (vlax-safearray->list (vlax-variant-value (vlax-get-property http 'responsebody)))
fic  (open file "w") n 0)
  (foreach byte tbl
    (if (eq byte 0)
      (princ (vl-list->string '(0)) fic)
      (write-char byte fic)
    )
  )
  (close fic)
  (vlax-release-object http)
  (princ)
)

Code: [Select]
(download "http://carnet-de-cablage.chez-alice.fr/Lisp/Latt.zip" "c:/")
@+

Hello Patrick.
On my computer, this code works! :)

Good idea with express  8-)

but the code works in my computer to
But if you launch the zip and extract the files, they're empty  :?

@+

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Download with vlisp
« Reply #12 on: February 26, 2007, 10:22:08 AM »
but the code works in my computer to
But if you launch the zip and extract the files, they're empty  :?

@+

All works for me!  :-)


Patrick_35

  • Guest
Re: Download with vlisp
« Reply #13 on: February 26, 2007, 11:04:52 AM »
Thanks Evgeniy
I don't understand.  :-(
It's a windows version ? . I work with Xp Professional.

@+

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Download with vlisp
« Reply #14 on: February 26, 2007, 11:10:04 AM »
Thanks Evgeniy
I don't understand.  :-(
It's a windows version ? . I work with Xp Professional.

@+

I too use XP Professional +SP2 (ru)
The program checked for AutoCAD 2007 +SP1 (en)