Jump to content

Recommended Posts

Posted

Hi ,

I know filename ( file.dvb)

i want to know the filepath in autolisp.

findfile searches in searchpath only.

 

But file may be anywhere else.

Can anyone help me?

Posted

Please check if the functions provided here are helping you.

Posted

Hi,

Let me explain,

I have my dvb file , may be placed anywhere(not static)

I want to load the file

filepath is not known, only filename(file.dvb) is known.

Posted

OK, I was under impression that you want to see the path from were was loaded an already loaded DVB.

You can write a recursive routine to search all folders from all available drives, but this will not be a very effective approach.

To narrow the search I suggest you to use a dedicated folder placed in the root of a drive (local or network).

(foreach theDrive '("C:\\" "D:\\" "E:\\")
(if (setq isValidPath (findfile (strcat theDrive "MyDVBFolder\\" "File.DVB")))
 (setq pathDVB isValidPath)
)
)

May use the McNeel's DosLib function DOS_DRIVEP to validate availability of a drive.

Posted

This will search on all possible drives and retain the first valid path encountered:

(setq listDrives '()
     index 66)
(foreach theDrive (reverse (repeat 24 
                                  (setq listDrives (cons (chr (setq index (1+ index)))
                                                         listDrives))))
(if (setq isValidPath (findfile (strcat theDrive ":\\MyDVBFolder\\" "File.DVB")))
 (if (not pathDVB) (setq pathDVB isValidPath))
)
)

Posted

@MSASU : you can use WMI to get list of all Drives ^^

Posted

Thanks for your suggestion, ketxu! I will have to investigate that.

Posted

FSO for drive letters

(defun _ValidDriveLetters  (/ fso dr)
     (setq fso (vlax-create-object "Scripting.FileSystemObject"))
     (vlax-for
            d  (vlax-get fso 'Drives)
           (setq dr (cons (vla-get-path d) dr)))
     (vlax-release-object fso)
     (reverse dr)
     )

 

(_ValidDriveLetters)

("C:" "D:" "E:" "V:")

Posted

@pBe, why path over driveletter property?

 

FSO:

(defun _driveletters ( / fso reslt )
   (if (setq fso (vlax-create-object "scripting.filesystemobject"))
       (progn
           (vl-catch-all-apply
              '(lambda ( )
                   (vlax-for drive (vlax-get fso 'drives)
                       (setq reslt (cons (vlax-get drive 'driveletter) reslt))
                   )
               )
           )
           (vlax-release-object fso)
           (vl-sort reslt '<)
       )
   )
)

WMI:

(defun _wmidriveletters ( / qry rslt srv wmi )
   (vl-catch-all-apply
      '(lambda ( )
           (setq wmi (vlax-create-object "wbemscripting.swbemlocator")
                 srv (vlax-invoke wmi 'connectserver)
                 qry (vlax-invoke srv 'execquery "Select DeviceID from Win32_LogicalDisk")
           )
           (vlax-for itm qry
               (vlax-for prop (vlax-get itm 'properties_)
                   (if (eq "DeviceID" (vlax-get prop 'name))
                       (setq rslt (cons (vlax-get prop 'value) rslt))
                   )
               )
           )
       )
   )
   (foreach obj (list qry srv wmi) (if obj (vlax-release-object obj)))
   (vl-sort rslt '<)
)

Posted
@pBe, why path over driveletter property?

 

To include ":"

 

Another for Mapped Newtwork Drive letter and name

(defun _NetDrive  (/ WscrptO Driveletter NDrive)
     (setq WscrptO     (vlax-create-object "WScript.Network")
           Driveletter (vlax-invoke WscrptO 'EnumNetworkDrives)
           )
     (repeat (setq i (vla-get-length Driveletter))
           (setq NDrive  (cons (vla-Item Driveletter (setq i (1- i)))
                            NDrive))
           )
     (vlax-release-object WscrptO)
     NDrive)

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