下载由 URL 指定的文件。 支持的平台:仅窗口 签名工 务 局: object.GetRemoteFile URL, LocalFile, IgnoreCache
返回值(RetVal)无返回值。 言论如果维护已在当前会话或上一个会话(缓存)中下载的文件列表,则避免重复传输并改为创建本地可用文件的副本可能更有效。您可以通过将IgnoreCache参数设置为 来显式强制下载,在这种情况下,将完全绕过缓存。True 访问安全 URL 时,将发布一个对话框,提示用户输入必要的密码信息。如果用户未在浏览器中禁止显示此活动,也会出现消息框。 下载文件时,AutoCAD 会创建一个临时文件进行内部处理。不要尝试访问此临时文件。此文件中的信息将在 AutoCAD 会话结束时删除。 例子工 务 局: Sub Example_GetRemoteFile() ' This example will prompt the user for a URL to download and will verify that ' a proper URL was entered. After downloading, the example will attempt to load ' the downloaded URL as a drawing. ' ' * Note: Remember to delete the downloaded file from your disk drive when finished. Dim Utility As AcadUtility Dim URL As String, DestFile As String, FileURL As String Set Utility = ThisDrawing.Utility ' Connect to Utility object GETURL: ' Prompt user for a URL to download. This should be a URL to an AutoCAD drawing file. URL = Utility.GetString(False, vbLf & "Enter the complete URL of the file you wish to download: ") URL = Trim(URL) ' Get rid of blank spaces If URL = "" Then Exit Sub ' Did user cancel ' Determine if user entered a valid URL; if not, prompt again If Not (Utility.IsURL(URL)) Then MsgBox "The URL you entered is not valid. Make sure the syntax is a valid URL." GoTo GETURL End If ' Download URL Utility.GetRemoteFile URL, DestFile, True ' Display downloaded file information MsgBox URL & " was downloaded to: " & DestFile ' Use IsRemoteFile to determine if this file was downloaded from a URL. ' If it was, display the URL it was downloaded from ' ' * Note: Although the results that IsRemoteFile will return are already known ' since the file was just downloaded it is important to know how this ' method can be used. If Utility.IsRemoteFile(DestFile, FileURL) Then MsgBox "The file: " & DestFile & " is a downloaded file and was downloaded from: " & FileURL Else MsgBox "The file: " & DestFile & " is not a downloaded file." End If End Sub Visual LISP: (vl-load-com) (defun c:Example_GetRemoteFile() ;; This example will prompt the user for a URL to download and will verify that ;; a proper URL was entered. After downloading, the example will provide information ;; about the downloaded drawing. ;; ;; * Note: Remember to delete the downloaded file from your disk drive when finished. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq Utility (vla-get-Utility doc)) ;; Connect to Utility object ;; Prompt user for a URL to download. This should be a URL to an AutoCAD drawing file. (setq URL (vla-GetString Utility :vlax-false "\nEnter the complete URL of the file you wish to download: ")) (if (/= URL "") (progn (if (= (vla-IsURL Utility URL) :vlax-false) (alert "The URL you entered is not valid. Make sure the syntax is a valid URL.") (progn ;; Download URL (vla-GetRemoteFile Utility URL 'DestFile :vlax-true) ;; Display downloaded file information (alert (strcat URL " was downloaded to: " DestFile "\n")) ;; Use IsRemoteFile to determine if this file was downloaded from a URL. ;; If it was, display the URL it was downloaded from ;; ;; * Note: Although the results that IsRemoteFile will return are already known ;; since the file was just downloaded it is important to know how this ;; method can be used. (if (= (vla-IsRemoteFile Utility DestFile URL) :vlax-true) (alert (strcat "The file: " DestFile " is a downloaded file and was downloaded from: " URL)) (alert (strcat "The file: " DestFile " is not a downloaded file.")) ) ) ) ) ) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:41
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.