Author Topic: MultiSelect Files by script  (Read 7686 times)

0 Members and 1 Guest are viewing this topic.

Patrick_35

  • Guest
MultiSelect Files by script
« on: October 02, 2006, 04:13:59 PM »
Hi

When i use
Code: [Select]
(setq she (vlax-create-object "userAccounts.CommonDialog"))
(vlax-put-property she 'filter (vlax-make-variant "Fichiers Texte| *.txt |Tous les fichiers|*.*"))
(vlax-put-property she 'filterindex 2)
(vlax-put-property she 'flags (+ 4 8 512 2048))
(vlax-put-property she 'initialdir (getvar "dwgprefix"))
(vlax-invoke she 'showopen)
A (vlax-get-property she 'filename) returns selectd files
But if i want a explorer presentation, i do

Code: [Select]
(vlax-put-property she 'flags (+ 4 8 512 2048 524288))
(vlax-invoke she 'showopen)
And if i look by (vlax-get-property she 'filename), i've just the repertory, don't files names  :?
Thanks

@+

Andrea

  • Water Moccasin
  • Posts: 2372
Re: MultiSelect Files by script
« Reply #1 on: October 04, 2006, 11:32:42 PM »
You must have

"drawing1.dwg" "drawing2.dwg" "drawing3.dwg" etc...

but your routine show...

drawing1.dwg drawing2.dwg drawing3.dwg etc...

without "cotes"...(sans les guillements)


you need also to check if the file is on "read-only" mode...

why not using script file ?
and put something like this..



Code: [Select]
(setq file (open "c:/windows/temp/filetemp.scr" "w"))
(foreach f list
(princ (strcat "_.open \" f "\n") file)
)
(vl-cmdf "_script" "c:/windows/temp/filetemp.scr")
« Last Edit: October 04, 2006, 11:43:31 PM by Andrea »
Keep smile...

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #2 on: October 05, 2006, 02:43:30 AM »
Thank you, it is nice to answer, but it is not exactly only I seek
By your method, you cannot choose (dwg or others), and i can use (vl-directory-files ...) to look a directory
The solution exists with doslib (function getfilem) and I'm persuaded that it's by the activeX that that is possible.
I'm there almost.
Patience et ténacité m'y feront arriver

@+

Andrea

  • Water Moccasin
  • Posts: 2372
Re: MultiSelect Files by script
« Reply #3 on: October 05, 2006, 05:17:20 PM »
Hi Patrik...

Ho's talking about multiplie file selection dialog box ??
your code is great...

Just, try to put your result on a script to open the selected file..

(ça marche bien pour mes programmes)   ;-)
Keep smile...

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #4 on: October 06, 2006, 02:41:26 AM »
If you use 524288 in the flags, you have an another presentation and a multiplie file selection, but where is the result ?

(je sais que ça fonctionne bien sans le bit 524288, mais avec, je le trouve plus conviviale)  ;-)

@+

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #5 on: October 06, 2006, 05:11:02 AM »
Ah, a precision. When I say about script, I think of the script of Windows, and not those of autocad

@+

Andrea

  • Water Moccasin
  • Posts: 2372
Re: MultiSelect Files by script
« Reply #6 on: October 06, 2006, 01:05:41 PM »
For info....

when you open multiple file in AutoCAD....
it show files between "" symbol.

see pictures..
« Last Edit: October 06, 2006, 01:08:17 PM by Andrea »
Keep smile...

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #7 on: October 06, 2006, 03:47:59 PM »
Yes, with (vlax-put-property she 'flags (+ 4 8 512 2048)), a (vlax-get-property she 'filename) return "C:\\acad\\ 10.dwg 123.dwg 1234.dwg 2.dwg"
A (vlax-put-property she 'flags (+ 4 8 512 2048 524288)), a (vlax-get-property she 'filename) return only "C:\\Acad"
Where are the files ?

Thanks

Fatty

  • Guest
Re: MultiSelect Files by script
« Reply #8 on: October 09, 2006, 09:53:15 AM »
Yes, with (vlax-put-property she 'flags (+ 4 8 512 2048)), a (vlax-get-property she 'filename) return "C:\\acad\\ 10.dwg 123.dwg 1234.dwg 2.dwg"
A (vlax-put-property she 'flags (+ 4 8 512 2048 524288)), a (vlax-get-property she 'filename) return only "C:\\Acad"
Where are the files ?

Thanks


Not sure about maybe I am wrong, my sorry in such case
I think that for a multiple-file selection, when
"FileName" property that returns a string list of the files,
delimited by spaces, this string length must be less or equal 256,
otherwise CommonDialog returns NIL.
(imho)

Code: [Select]
(defun getfiledex (ext msg1 msg2 / cdlg files fname fstr intr pos)
  (vl-load-com)
  (setq cdlg (vlax-create-object "UserAccounts.CommonDialog"))
  (vlax-put-property
    cdlg
    'Filter
    (vlax-make-variant (strcat msg1 ext msg2)))
  (vlax-put-property cdlg 'Filterindex 2)
  (vlax-put-property cdlg 'Flags (+ 4 8 512 2048))
  (vlax-put-property cdlg 'Initialdir (getvar "dwgprefix"))
  (setq intr (vlax-invoke cdlg 'ShowOpen))
  (if (not (zerop intr))
  (progn 
  (setq fname (vlax-get-property cdlg 'FileName))
  (vlax-release-object cdlg)

  (setq fstr (vl-string-left-trim
       (strcat (getvar "dwgprefix") " ")
       fname
     )
  )
  (while
    (setq pos (vl-string-search ext fstr))
     (setq files (cons (strcat (getvar "dwgprefix")
       (substr fstr 1 (+ pos 4))
       )
       files
)
     )
     (setq fstr (substr fstr (+ pos 5)))
  )
  )
    )
  files
)

;TesT: (setq lst (getfiledex "txt" "Fichiers Texte| *." ""))

Fatty

~'J'~
« Last Edit: October 09, 2006, 09:54:50 AM by Fatty »

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #9 on: October 09, 2006, 11:08:17 AM »
Thanks fatty
You have the same result of me
I have the impression that flag 524288 was not envisaged

@+

LE

  • Guest
Re: MultiSelect Files by script
« Reply #10 on: October 09, 2006, 01:38:01 PM »
No time to play a lot with your function... but you can try:

To call the function:
Code: [Select]
(getfiledex "*.dwg" "*.dwg||" "")

And use the flag of:
Code: [Select]
(vlax-put-property cdlg 'Flags 2626052) ;;(+ 4 8 512 2048))

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #11 on: October 10, 2006, 10:24:53 AM »
Thanks
Quote
(getfiledex "*.dwg" "*.dwg||" "")
It's don't work but
Code: [Select]
(getfiledex "*.dwg" "*.dwg|" "")is good, and your flags 2626052 don't use explorer interface

@+

chlh_jd

  • Guest
Re: MultiSelect Files by script
« Reply #12 on: March 02, 2011, 01:26:20 PM »
hi all
what about this way  :-)
Code: [Select]
;;; Modify Based on xiaomu(2005-10-12)
;;;****************************************************************************
;;; Function:  Select multiple files in Windows ( ACAD version requires more than R15.0)                         
;;;       This function uses MsComDlg.Commondialog object (Comdlg.OCX)                     
;;; E.G:  (ayGetMultFiles "Multiple Select" "*.dwg" "")
;;;       (ayGetMultFiles ""  "" "E:\\GSLS\\work\\")
;;; returns: ("C:\\DWG" "7b.dwg" "7c.dwg" "1.Dwg")                               
;;;****************************************************************************
(if
  (/=
    (vl-registry-read
      "HKEY_CLASSES_ROOT\\Licenses\\4D553650-6ABE-11cf-8ADB-00AA00C00905"
    )
    "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
  )
   (vl-registry-write
     "HKEY_CLASSES_ROOT\\Licenses\\4D553650-6ABE-11cf-8ADB-00AA00C00905"
     ""
     "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
   )
) ;end_if
(defun ayGetMultFiles (strTitle   strFilter  strInitDir /
       Maxfiles   Flags      WinDlg mFiles
       Catchit
      )
  (vl-load-com)
  (setq WinDlg (vlax-create-object "MSComDlg.CommonDialog"))
  (if (not WinDlg)
    (progn ;then
      (princ
"\n error: Operating system is not installed on the common-control Comdlg.OCX, please install it and then run!"
      )
      (setq mFiles nil)
    ) ;end_progn then
    (progn ;else
      (setq Maxfiles 32767)
      (setq Flags (+ 4 512 524288 1048576 1024))
      (vlax-put-property WinDlg 'CancelError :vlax-true)
      (vlax-put-property WinDlg 'MaxFileSize Maxfiles)
      (vlax-put-property WinDlg 'Flags Flags)
      (vlax-put-property WinDlg 'DialogTitle strTitle)
      (vlax-put-property WinDlg 'Filter strFilter)
      (vlax-put-property WinDlg 'InitDir strInitDir)
      (setq Catchit nil)
      (setq Catchit (vl-catch-all-apply
      '(lambda ()
(vlax-invoke-method WinDlg 'ShowOpen)
(setq mFiles (vlax-get WinDlg 'Filename))
       )
    )
      )
      (vlax-release-object WinDlg)
      (if (not (vl-catch-all-error-p Catchit)) ;error-handing
(ayFSTR->LST mFiles)
nil ;else
      ) ;end_if
    ) ;end_progn
  ) ;end_if
) ;end_defun
;;;************************************************
;;;function: spit dirs     
;;;E.G : "C:\\DWG1\0001.dwg\0002.dwg" -->   
;;;        ("C:\\DWG1" "1.dwg" "2.dwg")     
;;;************************************************
(Defun ayFSTR->LST (xMFileStr / mFileList k)
  (if (= xMFileStr "")
    (setq mFileList nil) ;then
    (progn
      (if (vl-string-position (ascii "\000") xMFileStr)
(progn
  (while (vl-string-position (ascii "\000") xMFileStr)
    (setq k (vl-string-position (ascii "\000") xMFileStr))
    (setq mFileList
   (append mFileList (list (substr xMFileStr 1 k)))
    )
    (setq xMFileStr (substr xMFileStr
    (+ k 2)
    (- (strlen xMFileStr) k 1)
    )
    )
  ) ;end_while
  (setq mFileList
(append mFileList
(list (vl-string-left-trim "\\" xMFileStr))
)
  )
) ;end_progn then
(progn
  (setq mFileList (vl-filename-directory xMFileStr))
  (setq
    mFileList (list mFileList
    (vl-string-left-trim
      "\\"
      (vl-string-subst "" mFileList xMFileStr)
    )
      )
  )
) ;end_progn else
      ) ;end_if
      mFileList
    ) ;end_progn
  ) ;end_if
) ;end_defun

Patrick_35

  • Guest
Re: MultiSelect Files by script
« Reply #13 on: March 07, 2011, 05:49:38 AM »
hi all
what about this way  :-)
Code: [Select]
;;; Modify Based on xiaomu(2005-10-12)
;;;****************************************************************************
;;; Function:  Select multiple files in Windows ( ACAD version requires more than R15.0)                         
;;;       This function uses MsComDlg.Commondialog object (Comdlg.OCX)                     
;;; E.G:  (ayGetMultFiles "Multiple Select" "*.dwg" "")
;;;       (ayGetMultFiles ""  "" "E:\\GSLS\\work\\")
;;; returns: ("C:\\DWG" "7b.dwg" "7c.dwg" "1.Dwg")                               
;;;****************************************************************************
(if
  (/=
    (vl-registry-read
      "HKEY_CLASSES_ROOT\\Licenses\\4D553650-6ABE-11cf-8ADB-00AA00C00905"
    )
    "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
  )
   (vl-registry-write
     "HKEY_CLASSES_ROOT\\Licenses\\4D553650-6ABE-11cf-8ADB-00AA00C00905"
     ""
     "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
   )
) ;end_if
(defun ayGetMultFiles (strTitle   strFilter  strInitDir /
       Maxfiles   Flags      WinDlg mFiles
       Catchit
      )
  (vl-load-com)
  (setq WinDlg (vlax-create-object "MSComDlg.CommonDialog"))
  (if (not WinDlg)
    (progn ;then
      (princ
"\n error: Operating system is not installed on the common-control Comdlg.OCX, please install it and then run!"
      )
      (setq mFiles nil)
    ) ;end_progn then
    (progn ;else
      (setq Maxfiles 32767)
      (setq Flags (+ 4 512 524288 1048576 1024))
      (vlax-put-property WinDlg 'CancelError :vlax-true)
      (vlax-put-property WinDlg 'MaxFileSize Maxfiles)
      (vlax-put-property WinDlg 'Flags Flags)
      (vlax-put-property WinDlg 'DialogTitle strTitle)
      (vlax-put-property WinDlg 'Filter strFilter)
      (vlax-put-property WinDlg 'InitDir strInitDir)
      (setq Catchit nil)
      (setq Catchit (vl-catch-all-apply
      '(lambda ()
(vlax-invoke-method WinDlg 'ShowOpen)
(setq mFiles (vlax-get WinDlg 'Filename))
       )
    )
      )
      (vlax-release-object WinDlg)
      (if (not (vl-catch-all-error-p Catchit)) ;error-handing
(ayFSTR->LST mFiles)
nil ;else
      ) ;end_if
    ) ;end_progn
  ) ;end_if
) ;end_defun
;;;************************************************
;;;function: spit dirs     
;;;E.G : "C:\\DWG1\0001.dwg\0002.dwg" -->   
;;;        ("C:\\DWG1" "1.dwg" "2.dwg")     
;;;************************************************
(Defun ayFSTR->LST (xMFileStr / mFileList k)
  (if (= xMFileStr "")
    (setq mFileList nil) ;then
    (progn
      (if (vl-string-position (ascii "\000") xMFileStr)
(progn
  (while (vl-string-position (ascii "\000") xMFileStr)
    (setq k (vl-string-position (ascii "\000") xMFileStr))
    (setq mFileList
   (append mFileList (list (substr xMFileStr 1 k)))
    )
    (setq xMFileStr (substr xMFileStr
    (+ k 2)
    (- (strlen xMFileStr) k 1)
    )
    )
  ) ;end_while
  (setq mFileList
(append mFileList
(list (vl-string-left-trim "\\" xMFileStr))
)
  )
) ;end_progn then
(progn
  (setq mFileList (vl-filename-directory xMFileStr))
  (setq
    mFileList (list mFileList
    (vl-string-left-trim
      "\\"
      (vl-string-subst "" mFileList xMFileStr)
    )
      )
  )
) ;end_progn else
      ) ;end_if
      mFileList
    ) ;end_progn
  ) ;end_if
) ;end_defun
Very nice  :-)

Thank you very much

@+

chlh_jd

  • Guest
Re: MultiSelect Files by script
« Reply #14 on: March 08, 2011, 07:13:20 PM »
You're welcome !