TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Patrick_35 on October 02, 2006, 04:13:59 PM
-
Hi
When i use
(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
(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
@+
-
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..
(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")
-
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
@+
-
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) ;-)
-
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) ;-)
@+
-
Ah, a precision. When I say about script, I think of the script of Windows, and not those of autocad
@+
-
For info....
when you open multiple file in AutoCAD....
it show files between "" symbol.
see pictures..
-
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
-
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)
(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'~
-
Thanks fatty
You have the same result of me
I have the impression that flag 524288 was not envisaged
@+
-
No time to play a lot with your function... but you can try:
To call the function:
(getfiledex "*.dwg" "*.dwg||" "")
And use the flag of:
(vlax-put-property cdlg 'Flags 2626052) ;;(+ 4 8 512 2048))
-
Thanks
(getfiledex "*.dwg" "*.dwg||" "")
It's don't work but
(getfiledex "*.dwg" "*.dwg|" "")
is good, and your flags 2626052 don't use explorer interface
@+
-
hi all
what about this way :-)
;;; 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
-
hi all
what about this way :-)
;;; 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
@+
-
You're welcome !
-
More info:
http://www.theswamp.org/index.php?topic=14715.msg177776#msg177776
http://www.theswamp.org/index.php?topic=14715.msg177779#msg177779