Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Create a list of drawings and write them to a text file

  1. #11
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    Ima gonna date myself here (remember dos?)

    P-

    Code:
    (defun FolderToList (strFolder)
     (command "shell" (strcat "dir " strFolder "*.dwg /b /t > Files.txt"))
     (command "notepad" (findfile "Files.txt"))
    )
    syntax

    Code:
    (foldertolist "C:\\ACAD\\LISP\\")
    AutomateCAD

  2. #12
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    That is what I was thinking,

    Bat file:
    DIR "*.dwg" /S /A /ONE /B > dwglist.txt

  3. #13
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    Quote Originally Posted by framedNlv View Post
    That is what I was thinking,

    Bat file:
    DIR "*.dwg" /S /A /ONE /B > dwglist.txt
    Working like a charm
    But there is a problem with my russian encoding,
    I got some unreadable characters take a look at please:

    C:\Users\Ћ«ҐЈ\Programming\FORUMS\Augi\bcount.dwg
    C:\Users\Ћ«ҐЈ\Programming\FORUMS\Augi\bigsize.dwg

    Is there way to add local encoding to your bat file?
    Regards,
    Oleg

    ~'J'~

  4. #14
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    Quote Originally Posted by fixo View Post
    Working like a charm
    But there is a problem with my russian encoding,
    I got some unreadable characters take a look at please:

    C:\Users\Ћ«ҐЈ\Programming\FORUMS\Augi\bcount.dwg
    C:\Users\Ћ«ҐЈ\Programming\FORUMS\Augi\bigsize.dwg

    Is there way to add local encoding to your bat file?
    Regards,
    Oleg

    ~'J'~
    I'm not sure about the dos end of it, but you should be able to use find & replace in notepad or excel to fix it.

  5. #15
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    Thanks for solution
    Have a nice weekend
    Cheers

    Oleg

  6. #16
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    This program is for building a list of individual drawing files(not the entire folder) including several folder locations and drives, which is used by another program to index content.
    Thought I would post it on AUGI because I've seen other requests about it.

    The DOS solution is very cool though.
    Last edited by aaronic_abacus; 2012-03-16 at 08:46 PM.

  7. #17
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    I have a bat file on my desktop, I drop it in a folder and do an index for one reason or another, plus I hate the new windows search 4.0.

  8. #18
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    how would i display the path(variable) in a dialog box?

  9. #19
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    Try this code this will write DCL dynamically,
    almost not tested though

    Code:
    ;    borrowed from Tony Tanzillo Maestro Guru    ;
    
    (defun browse-folder (msg path / sh fld folderobject result)
      (vl-load-com)
      (setq    sh (vla-getInterfaceObject
             (vlax-get-acad-object)
             "Shell.Application"
           )
      )
      (setq    fld (vlax-invoke-method
              sh 'BrowseForFolder
              vlax-vbDefaultButton1
              msg          ; dialogue box message
              vlax-vbDefaultButton3     ; BIF_NONEWFOLDERBUTTON Bruno Toniutti
              path                  ; path start
    )
      )
      (vlax-release-object sh)
      (if fld
        (progn
          (setq folderobject (vlax-get-property fld 'Self))
          (setq result (vlax-get-property folderObject 'Path))
          (vlax-release-object fld)
          (vlax-release-object folderobject)
          result
        )
      )
    )
    
    ;                        ;
    
    (defun list-dwg    (path / file_list full_list)
      (setq    file_list
         (vl-directory-files path "*.dwg" 1)
      )
      (setq    file_list
              (mapcar (function (lambda (x) (strcat path "\\" x)))
                  file_list
              )
        full_list (append full_list file_list)
      )
      full_list
    )
    
    (defun C:fileDia(/ dcl_contents  dcl_id  file fname folder  listfiles result returnlist)
    
    (setq folder (browse-folder "Select Folder: " "C:\Test"))
      
    (setq drawings (list-dwg folder))
    
    (setq dcl_contents  
    "dcl_settings : default_dcl_settings { audit_level = 3; }
    
    dwglist : dialog {
      key = \"fd\";
      label = \"Files\";
      spacer;
      : row {
        alignment = centered;
        fixed_width = true;
        
              : list_box {
                key = \"drws\";
                width = 42;
                     height = 18;       
                fixed_width = true;
                multiple_select=true;
              }
            }
      spacer;
      : row {
        alignment = centered;
        fixed_width = true;
        : ok_button {
          width = 11;
        }
        : cancel_button {
          width = 11;
        }
        }
        }"
          )
      (setq fname (strcat (getvar 'dwgprefix) "myfiles.dcl"))
      (setq file (open fname "w"))
      (write-line dcl_contents file)
      (close file)
    
      (if
        (>= (setq dcl_id (load_dialog "myfiles")) 0)
        (if
          (new_dialog "dwglist" dcl_id)
          (progn
            (start_list "drws")
    	(mapcar 'add_list drawings)
    	(end_list)
    
            (action_tile "drws" "(setq ListFiles $value)")
    
            (set_tile "accept" "(alert \"Work with selected file\")(done_dialog 1)")
            (set_tile "cancel" "(done_dialog 0)")
            
            (setq result (start_dialog))
            (unload_dialog dcl_id)
    	(if (= 1 result)
       (progn
    	(setq  ListFiles (read (strcat "(" ListFiles ")")))
               (setq ReturnList (mapcar '(lambda (x) (nth x drawings)) ListFiles ))
         (setq msg "")
    	   (foreach ff ReturnList
    	     (setq msg (strcat msg  ff "\n")))
         (alert msg)
    	   ))
            )
          (princ "\nWrong dialog definition")
          )
        (princ "\nDCL file not found")
      )
      
      (princ)
      )

  10. #20
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: Create a list of drawings and write them to a text file

    This is the final result with out backward slashes and a funny name "lookdb"

    Code:
    (defun C:LOOKDBD (); / dcl_id driveNames numOfDrives iCounter selectedDriveNumber strDriveLetter strDrive directoryNames numOfDirs selectedDirectorNumbers)
     (setq sds nil)
     (setq selectedFileNumberList2 nil)
     (setq iCounter2 nil)
     (setq subdir nil)
     (setq directoryNames nil)
    
     (if (< (setq dcl_id (load_dialog "LOOKDBD.DCL")) 0) (exit))
     (if (not (new_dialog "TEST_WINDOW" dcl_id)) (exit))
     (setq driveNames (getdrives))
     (setq numOfDrives (length driveNames))
     (setq iCounter 0)	
     (repeat numOfDrives
      (add_list (nth iCounter driveNames))
      (setq iCounter (1+ iCounter))
     );;repeat
     (start_list "listDrives")
     (mapcar 'add_list driveNames)
     (end_list)
    
     (action_tile "select_dir" "(setq selectedDriveNumber (get_tile \"listDrives\"))
      (setq strDriveLetter (nth (atoi selectedDriveNumber) driveNames))
      (setq strDrive (strcat strDriveLetter \":\\\\\"))
      (if (/= strDrive strDrivet) (progn (setq directoryNames nil) (setq strDrivet strDrive) (setq sds nil)))
      (if (= directoryNames nil)
       (progn
        (setq directoryNames (vl-directory-files strDrive nil -1))
        (setq numOfDirs (length directoryNames))
        (setq iCounter 0)	
        (start_list \"listDirectories\")
        (repeat numOfDirs  
         (add_list (nth iCounter directoryNames))
         (setq iCounter (1+ iCounter))
        );;repeat
        (end_list)
        (setq strDrivet strDrive)
       );end progn
       (progn
        (setq subdirs (get_tile \"listDirectories\"))
        (setq subdirn (atoi subdirs))
        (setq subdir(nth subdirn directoryNames))
        (if (= subdir \".\") (progn (setq sds strDrive) (setq subdir \"\")))
        (if (/= sds nil) (setq sdst (substr sds 1 3)))
        (if (/= sds nil) 
         (if (/= sdst strDrive) 
          (progn 
           (setq sds nil)
           (setq subdir \"\")
           (setq strDrivet nil)
          );end progn
         );end if
        );end if
        (if (= sds nil)
         (if (/= subdir nil)
          (setq sds (strcat strDrive subdir))
          (setq sds strDrive)
         );end if
         (setq sds (strcat sds \"\\\\\" subdir))
        );end if
        (setq directoryNames (vl-directory-files sds nil -1))
        (setq numOfDirs (length directoryNames))
        (setq iCounter 0)
        (start_list \"listDirectories\")
        (repeat numOfDirs
         (add_list (nth iCounter directoryNames))
         (setq iCounter (1+ iCounter))
        );;repeat
        (setq sds (VL-STRING-SUBST \"\\\\\" \"\\\\\\\\\" sds))
        (if (= subdir \"..\")
         (progn
          (setq sdsl (strlen sds))
          (setq ct2 sdsl)
          (setq ct3 0)
          (setq lp2 1)
          (while lp2
           (setq sdsc (substr sds ct2 1))
           (setq ct2 (- ct2 1))
           (if (= sdsc \"\\\\\") (setq ct3 (+ ct3 1)))
           (if (= ct3 1)
            (progn
             (setq sds (substr sds 1 ct2))
           ));end progn if
           (if (= ct3 2)
            (progn
             (setq subdir (substr sds (+ ct2 1)))
             (if (= subir \"\\\\\") (setq subdir \"\"))
             (setq lp2 nil)
           ));end progn if
          );end lp2
        ));end progn if
        (end_list)
      ));end progn if
      "
     );action_tile "select_dir"
    
     (action_tile "process_files" "(setq selectedDirectorNumbers (get_tile \"listDirectories\"))
      (setq selectedDirectoryNumber (read selectedDirectorNumbers))
      (if (/= selectedDirectoryNumber nil)
       (progn
        (setq selectedDirectory(nth selectedDirectoryNumber directorynames)) 	
        (if (= sds nil)
         (setq selectedfilePath(strcat strDriveLetter \":\\\\\" selectedDirectory))
         (progn
          (setq sdsl3 (strlen sds))
          (setq sdsc3 (substr sds sdsl3 1))
          (if (= sdsc3 \"\\\\\")
           (setq selectedfilePath(strcat sds selectedDirectory))
           (setq selectedfilePath(strcat sds \"\\\\\" selectedDirectory))
          );end if
         );end progn
        );end if
        (setq dwgNames (vl-directory-files selectedfilePath \"*.dwg\" 1)) ;;get the dwg files for selected directory
        (setq numOfFiles (length dwgNames))
        (setq iCounter 0)	
        (start_list \"listFiles\")
        (repeat numOfFiles  
         (add_list (nth iCounter dwgNames))
         (setq iCounter (1+ iCounter))
        );;repeat  
        (end_list)
       );progn
       (alert \"Nothing selected\")
      );if
      "
     );action_tile "process_files"
    
    
    
     (action_tile "addbatch_dwgs" "(setq selectedFileNumbers (get_tile \"listFiles\"))
      (setq selectedFileNumber (read selectedFileNumbers))
      (if (= selectedFileNumberList2 nil) (setq selectedFileNumberList2 (list \"\")))
      (if (/= selectedFileNumber nil)
       (progn
        (setq selectedFileNumberList (MK_LIST selectedFileNumbers))
        (foreach n selectedFileNumberList
         (setq lim (strcat selectedfilePath \"\\\\\" n))
         (setq selectedFileNumberList2 (append selectedFileNumberList2 (list lim)))
        );end foreach
        (if (= (car selectedFileNumberList2) \"\") (setq selectedFileNumberList2 (cdr selectedFileNumberList2)))
        (setq NumOfFilesInList (length selectedFileNumberList2))
        (setq iCounter2 0)
        (start_list \"listBatch\")
        (repeat NumOfFilesInList
         (setq selectedFile(nth iCounter2 selectedFileNumberList2))
         (setq ifad (nth iCounter2 selectedFileNumberList2))
         (if (/= ifad \"\") (add_list ifad))
         (setq iCounter2 (1+ iCounter2))
        );repeat
        (end_list)
       );progn
       (alert \"Nothing selected\")
      );if
      "
     );action_tile "addbatch_dwgs"
    
     (action_tile "process_dwgs" "(setq selectedFileNumbers (get_tile \"listBatch\"))
      (setq selectedFileNumber (read selectedFileNumbers))
      (setq ldbfm (open \"lookdb.ldb\" \"w\"))
      (setq sfnmm selectedFileNumberList2)
      (setq NumOfFilesInList (length sfnmm))
      (setq iCounter 0 )
      (repeat NumOfFilesInList
       (setq selectedFile(nth iCounter sfnmm)) 	
       (write-line selectedFile ldbfm)
       (setq iCounter (1+ iCounter))
      );repeat
      (close ldbfm)
      (SETQ LDBGO \"GO\")
      (done_dialog 0)
      "
     );action_tile "process_dwgs"
    
    
      (start_dialog)
    
      (unload_dialog dcl_id)
    
      (princ)
    )
    
    (defun MK_LIST  (readlist / count item retlist)
      (setq count 1)
      (while (setq item (read readlist))
        (setq retlist (cons (nth item dwgNames) retlist))
        (while (and (/= " " (substr readlist count 1))
          (/= "" (substr readlist count 1)))
          (setq count (1+ count)) )
        (setq readlist (substr readlist count)) )
      (reverse retlist)
    )
    
    ;; Begin Code
    (defun GetDrives ( / wshFSO driveObjs)
      (vl-load-com)
    
      (if (= wshLibImport nil)
        (progn
          (vlax-import-type-library :tlb-filename "wshom.ocx"
                              :methods-prefix "wshm-"
                              :properties-prefix "wshp-"
                              :constants-prefix "wshk-"
          )
          (setq wshLibImport T)
        )
      )
    
      (setq wshFSO (vlax-create-object "Scripting.FileSystemObject"))
      (setq driveObjs (wshp-get-Drives wshFSO))
    
      (setq myList nil)
      (setq myList2 nil)
      
      
      (vlax-for driveObj driveObjs
        (progn
          
          (setq myList (list (vlax-get-property driveObj 'DriveLetter)))
          (setq myList2 (append myList2 myList))
          
       
        )
      )
    )
    ;; End Code
    Attached Files Attached Files
    Last edited by aaronic_abacus; 2014-11-26 at 07:44 AM.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. 2011: Program to Create Drawings Using DXF File Format
    By stusic in forum AutoCAD General
    Replies: 3
    Last Post: 2014-03-05, 01:18 PM
  2. Write usernames to text file
    By mikelf in forum AutoLISP
    Replies: 8
    Last Post: 2009-01-31, 09:33 PM
  3. Create consultant's drawings list
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2008-10-21, 12:53 PM
  4. Read / Write To Text File
    By caddog71 in forum VBA/COM Interop
    Replies: 2
    Last Post: 2008-05-27, 06:40 PM
  5. Replies: 10
    Last Post: 2007-10-09, 01:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •