Jump to content

autolisp access internet?


techjunkie09

Recommended Posts

Is it possible to make a lisp communicate with a server? Example would be that data for a series of diagrams could be stored using an sql database on a server and the lisp could be used to load the data off the shared database

Link to comment
Share on other sites

Hi

 

With autolisp, no, but with vlisp, yes

 

Look vla-putremotefile/vla-getremotefile

 

or with

(setq ado (vlax-create-object "ADODB.Stream"))

or

(or (setq http (vlax-create-object "MSXML2.XMLHTTP"))
   (setq http (vlax-create-object "Microsoft.XMLHTTP"))
)

@+

Link to comment
Share on other sites

hate to be a little lazy on this bit, but is it possible to send an HTTP POST request with vlisp? Basically i'd like to have the lisp send a string of text to the server then have the server respond with a number, i can handle the server bit i just need to know how to send the request and how it receives a response

Link to comment
Share on other sites

Very nice. I'm definitely going to look into this further.

 

Can you use this to change stuff on a server as well? Like, take a file (say a simple text file), alter its contents and save it?

Link to comment
Share on other sites

Very nice. I'm definitely going to look into this further.

 

Can you use this to change stuff on a server as well? Like, take a file (say a simple text file), alter its contents and save it?

 

Hi

 

Yes, you can download a file, change it and upload

 

An example to download (without vla-getremotefile)

 

(defun download (url dir / byte fic file fso http ok tbl taille)
 (setq http (vlax-create-object "MSXML2.XMLHTTP")
       fso  (vlax-create-object "Scripting.FileSystemObject")
   file (strcat dir (vl-filename-base url) (vl-filename-extension url)))
 (vlax-invoke-method http 'open "get" url :vlax-false)
 (if (vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke (list http 'send)))
   (princ (strcat "\nLe lien " url " n'est pas valide."))
   (if (eq (vlax-get http 'status) 200)
     (if (vl-catch-all-error-p (setq taille (vl-catch-all-apply 'vlax-invoke (list http 'getResponseHeader "Content-Length"))))
   (princ "\nErreur de lecture sur la taille du fichier.")
       (if (< (atoi taille) (vlax-get (vlax-invoke fso 'getdrive (substr (vlax-invoke fso 'getabsolutepathname file) 1 1)) 'freespace))
     (progn
       (princ "\nTéléchargement en cours...")(princ)
       (while (not (eq (vlax-get http 'readystate) 4))
         (vla-eval (vlax-get-acad-object) "DoEvents")
       )
       (setq tbl (vlax-safearray->list (vlax-variant-value (vlax-get-property http 'responsebody))))
       (if (vl-catch-all-error-p (setq fic (vl-catch-all-apply 'vlax-invoke (list fso 'createtextfile file))))
         (princ (strcat "\nImpossible de créer le fichier " file))
         (progn
       (foreach byte tbl
         (vlax-invoke fic 'write (vl-list->string (list byte)))
       )
       (vlax-invoke fic 'close)
       (setq ok T)
         )
       )
     )
   )
     )
     (princ (strcat "\n" (vlax-get http 'statustext) "...Erreur " (itoa (vlax-get http 'status)) "."))
   )
 )
 (vlax-release-object http)
 (vlax-release-object fso)
 ok
)

(download "http://carnet-de-cablage.chez-alice.fr/Lisp/Latt.zip" "c:/")

@+

Link to comment
Share on other sites

Wow.. that is so awesome.. I can make 2-player Internet Pong with that.. or an AutoCAD MUD...

 

You've given me a new toy to play with. :3

Link to comment
Share on other sites

  • 7 years later...

I don't understand where/how to get a url for a file (for get) or directory (for put). Can this be on my local pc, or does it have to be hosted on an http file server? Where do you host it?

 

My end goal (in case this is already done), is to set up a sort of license server. It should check remotely for a valid license (if this is a slow process, it could be once per day) and then send out information about the drawing being worked on. Like directory path, etc.

 

Sorry once again if the answer is obvious. I'm still a total amateur who gets stuff done by just investing the hours needed for trial and error programming. I spent 4 hours this weekend to figure out Amazon AWS from the command line. That works pretty cool, it uses a line of text at the command prompt to transfer files. But I couldn't seem to "command" the line from within lisp, in a way that waited for the AWS response. Maybe I was doing it wrong? I was trying "_.script"

 

So I guess that's 2 questions in one. URL to a local pc, or where is it? And running a line of script for Windows.

Link to comment
Share on other sites

Search here for words like remote & license & protection & ??? it was a long time ago but it was same question how to get a license request from remote server. Or google. I downloaded it but never used it, now where did I put it.

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...