Jump to content

Mulitple vlisps at once?


CADWarrior

Recommended Posts

I am using the vla-getremotefile method to download information from a SQL Database and then store it onto a client's AutoCAD but the issue is some of these files fairly large and causes AutoCAD to just lock up while it downloads. Now I would love to show the download progress of it while it’s downloading using the downloaded size vs. File size.

 

Is it possible to do this?

 

Or if the above isn’t possible, I know this goes against everything I ever learned in VLISP, but is it possible to run multiple lisps at once.

 

Note this is an example of what I would like. This code does not work or at least shouldn't.

 
(setq util (vla-get-Utility (vla-get-ActiveDocument (vlax-get-acad-object))))
(setq http (vlax-create-object "MSXML2.XMLHTTP"))
(setq url  "[url]http://www.xyz.com/zyx.html[/url]" )
(setq filename "c:\\blah\\blah\\")
(setq extname (strcat filename (vl-filename-base url) (vl-filename-extension url)))
(vlax-invoke-method http 'open "get" url :vlax-false)
(vlax-invoke  http 'send)
(setq total (vl-catch-all-apply 'vlax-invoke (list http 'getResponseHeader "Content-Length")))
(while (vla-getremotefile util url filename :vlax-true)
(* (/ (vl-file-size extname) total) 100)
)

While downloading compare the downloaded size vs. total file size.

 

Any help you guys could provide would be great. I don't want to switch to Shell/CMD to download :cry:

 

Thanks in advance,

 

CADWarrior

Edited by CADWarrior
Link to comment
Share on other sites

MSXML2.XMLHTTP reference

 

http://msdn.microsoft.com/en-us/library/ms534361%28v=vs.85%29.aspx

 

You might be able to get the file size by using 'getAllResponseHeaders method, however; as the subsequent quote states you can't determine partial file size until the process has finished 'readyState 4

 

"You cannot call responseBody and responseText properties to obtain partial results (readyState = 3). Doing so will return an error, because the response is not fully received. You must wait until all data has been received."

 

You might want to have a look into other options, perhaps an ftp extension or a socket

 

SOliver

Link to comment
Share on other sites

Darn alright thank you alanjt.

 

SOliver the

(vl-catch-all-apply 'vlax-invoke (list http 'getResponseHeader "Content-Length"))

was just a temporary place holder for a future build. Just have not had time to get to it yet.

 


[list=1]
[*]Send Client Information to Server.
[*]Retrieve required information for client
[*]Post back information
[list=1]
[*]"File Name"; "Size in bytes"
[*]"Downloader.fas";"32424"
[/list]

[*]Autocad will then run a download function (similar to last post) for each "list" in the post back information.
[/list]

PHP can find the file size of a file already on the server without having to be in readystate 4. So it can just return the value its self without having to load it first.

 

My main question is, is it possible to track the process of vla-getremotefile while it downloads?

Link to comment
Share on other sites

Darn alright thank you alanjt.

 

SOliver the

(vl-catch-all-apply  'vlax-invoke (list http 'getResponseHeader "Content-Length"))

was just a temporary place holder for a future build. Just have not had time to get to it yet.

 



[list=1]
[*]Send Client Information to Server.
[*]Retrieve required information for client
[*]Post back information
[list=1]
[*]"File Name"; "Size in bytes"
[*]"Downloader.fas";"32424"
[/list]
[*]Autocad will then run a download function (similar to last post) for each "list" in the post back information.
[/list]

PHP can find the file size of a file already on the server without having to be in readystate 4. So it can just return the value its self without having to load it first.

 

My main question is, is it possible to track the process of vla-getremotefile while it downloads?

Sorry CADWarrior; reading the response again I noticed I'd completely forgot about the question in the title. alanjt has it covered. I don't think the task requires multiple scripts running.

 

You could make two requests one for the file size and one for the file. Keep looping until the ready state is 4 while checking the file size.

 

Sort of pushing the ftp idea http://www.networksorcery.com/enp/protocol/ftp.htm You wouldn't need an additional php file transfer (hehe), protocol.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...