Author Topic: Tool for "Open with Drag&Drop from filelists"  (Read 2131 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Tool for "Open with Drag&Drop from filelists"
« on: November 01, 2010, 08:54:33 AM »
High

rather often I have lists with filenames, stored in TXT or XLS, like this:

Code: [Select]
c:\test\a.dwg
d:\hello\project\data\drawings\12345.dwg
d:\hello\project\data\drawings\123456.dwg

Now I'm looking for a tool which helps me to open this file in "one click", like "Drag & Drop filelists".

Does exist a tool which make it?

Regards

Peter

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: Tool for "Open with Drag&Drop from filelists"
« Reply #1 on: November 01, 2010, 11:47:43 AM »
You could read the file into a simple DCL list_box, then open it using that perhaps  :-)

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: Tool for "Open with Drag&Drop from filelists"
« Reply #2 on: November 01, 2010, 12:38:54 PM »
Following from my above post....

Perhaps try something along these lines:

Code: [Select]
(defun c:OpenFile ( / *error* source dcl ofile lst nl dcfile dcH ptr flag doc )
  ;; © Lee Mac 2010

  (defun *error* ( msg )
   
    (if ofile (close ofile))
    (if dcH   (unload_dialog dcH))

    (if (findfile dcfile) (vl-file-delete dcfile))
   
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )
 
[color=red]  ;; -- Source for Filenames --
  (setq source "C:\\source.txt")[/color]

  (setq dcl
   '(
     "OpenFile : dialog { label = \"Select File to Open\";"
     "  spacer;"
     "  : list_box { "
     "    key = \"lst\"; alignment = centered; width = 60; height = 20;"
     "    allow_accept = true;"
     "  }"
     "  spacer;"
     "  ok_cancel;"
     "}"
    )
  )

  (cond
    (
      (not
        (and (setq ofile (open source "r"))
          (progn
            (setq lst
              (reverse
                (while (setq nl (read-line ofile))
                  (setq lst (cons nl lst))
                )
              )
            )
            (setq ofile (close ofile))
            lst
          )
        )
      )
     
      (princ "\n** Source File Empty or Nonexistent **")
    )   
    (
      (not
        (and
          (progn
            (setq dcfile (vl-filename-mktemp nil nil ".dcl")
                  ofile  (open dcfile "w")
            )
            (mapcar '(lambda ( l ) (write-line l ofile)) dcl)
            (setq ofile (close ofile))

            (< 0 (setq dcH (load_dialog dcfile)))
          )
          (new_dialog "OpenFile" dcH)
        )
      )

      (vl-file-delete dcfile)
      (princ "\n** DCL could not be loaded **")
    )
    (t
      (start_list "lst")
      (mapcar 'add_list lst)
      (end_list)

      (setq ptr (set_tile "lst" "0"))
      (action_tile "lst" "(setq ptr $value)")

      (setq flag (start_dialog) dcH (unload_dialog dcH))
      (vl-file-delete dcfile)

      (if (= 1 flag)
       
        (if (and (setq file (findfile (nth (atoi ptr) lst)))
              (not
                (vl-catch-all-error-p
                  (setq doc
                    (vl-catch-all-apply 'vla-Open
                      (list (vla-get-Documents (vlax-get-acad-object)) file)
                    )
                  )
                )
              )
            )
          (vla-Activate doc)
          (princ "\n** Error Attempting to Open file **")
        )

        (princ "\n*Cancel*")
      )
    )
  )

  (princ)
)

Edit the part marked in red to suit.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Tool for "Open with Drag&Drop from filelists"
« Reply #3 on: November 01, 2010, 02:45:10 PM »
This would work good with a bat file to create your drawing list:

MKDIR C:\Arch_Custom\Support\Batch
DIR *.DWG/B/S > "C:\Arch_Custom\Support\Batch\PLOT.Q"
DIR *.DWG/B > "C:\Arch_Custom\Support\DWG_List.txt"
DIR *.DWG/B/S > "C:\Arch_Custom\Support\DWG_Full_Path_List.txt"
NOTEPAD "C:\Arch_Custom\Support\DWG_Full_Path_List"
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Peter

  • Guest
Re: Tool for "Open with Drag&Drop from filelists"
« Reply #4 on: November 02, 2010, 06:38:54 AM »
Hi all

2Lee Mac
Maybe this code would work, but it is not comfortabel if the list already exists in another file (word, excel, outlook, ..) and/or there is a list with 100 files and I want to open file 1-5 and then file 34-43 and so on.

2GDF
Thanks, but making the list is not the problem.

Peter

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: Tool for "Open with Drag&Drop from filelists"
« Reply #5 on: November 02, 2010, 04:19:00 PM »
2Lee Mac
Maybe this code would work, but it is not comfortabel if the list already exists in another file (word, excel, outlook, ..) and/or there is a list with 100 files and I want to open file 1-5 and then file 34-43 and so on.

It was just proof of concept - not a complete application - that's for you to construct  ;-)