TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: KewlToyZ on July 27, 2009, 03:15:22 PM

Title: Create project folders?
Post by: KewlToyZ on July 27, 2009, 03:15:22 PM
I am looking to create a project folder structure automatically.
I was wondering if this was possible from lisp without arx?
Would I need DosLib to do it?
Title: Re: Create project folders?
Post by: GDF on July 27, 2009, 04:43:55 PM
I am looking to create a project folder structure automatically.
I was wondering if this was possible from lisp without arx?
Would I need DosLib to do it?

Yes DosLib can do it.

Code: [Select]
(defun ARCH:CustomSupportFolder  (/ F_LST)
  (setvar "cmdecho" 0)
  (command "filedia" "0")
  (setq F_LST (findfile "C:\\Arch_Custom\\Arch_Custom.ico"))
  (cond
    ((= F_LST nil)
     (progn

       (ARCH:MsgBox2 " Arch Program : Info" 48 "
     Arch Program Custom Support Folder
--------------------------------------------------------------------------------------------
     Creating C:\\Arch_Custom Personal Folder..." 4)

       (dos_copy
         (strcat ARCH#CUSF "Workstation\\Arch_Custom")
         "C:\\Arch_Custom")
       (dos_copy
         (strcat ARCH#CUSF "Workstation\\Arch_Custom\\*")
         "C:\\Arch_Custom")
       (dos_copy
         (strcat ARCH#CUSF "Workstation\\Arch_Custom\\SaveFile")
         "C:\\Arch_Custom")
       (dos_copy
         (strcat ARCH#CUSF "Workstation\\Arch_Custom\\Support")
         "C:\\Arch_Custom")
       (dos_copy
         (strcat ARCH#CUSF "Workstation\\Arch_Custom\\Support\\*")
         "C:\\Arch_Custom\\Support"))))
  (command "filedia" "1")
  (setvar "cmdecho" 1))
Title: Re: Create project folders?
Post by: T.Willey on July 27, 2009, 04:47:57 PM
I don't really understand what you mean, but lisp can make directories.  vl-mkdir
Title: Re: Create project folders?
Post by: gile on July 27, 2009, 05:00:29 PM
Hi,

You can have a look to the `FilesystemObject' ActiveX.

Example to create a folder
Code: [Select]
(defun CreateFolder (path / fso)
  (setq fso (vlax-create-object "Scripting.FilesystemObject"))
  (if (= (vlax-invoke-method fso 'FolderExists path) :vlax-false)
    (vlax-invoke-method fso 'CreateFolder path)
    (princ (strcat "\nThe folder \"" path "\" already exists."))
  )
  (vlax-release-object fso)
  (gc)
)

A dump on an fso object:
Quote
IFileSystem3: FileSystemObject
; Valeurs de propriétés:
;   Drives (RO) = #<VLA-OBJECT IDriveCollection 06da4f88>
; Méthodes prises en charge:
;   BuildPath (2)
;   CopyFile (3)
;   CopyFolder (3)
;   CreateFolder (1)
;   CreateTextFile (3)
;   DeleteFile (2)
;   DeleteFolder (2)
;   DriveExists (1)
;   FileExists (1)
;   FolderExists (1)
;   GetAbsolutePathName (1)
;   GetBaseName (1)
;   GetDrive (1)
;   GetDriveName (1)
;   GetExtensionName (1)
;   GetFile (1)
;   GetFileName (1)
;   GetFileVersion (1)
;   GetFolder (1)
;   GetParentFolderName (1)
;   GetSpecialFolder (1)
;   GetStandardStream (2)
;   GetTempName ()
;   MoveFile (2)
;   MoveFolder (2)
;   OpenTextFile (4)
Title: Re: Create project folders?
Post by: JohnK on July 28, 2009, 08:45:41 AM
without ARX (assuming you mean the VL functions).

Simplest way is the use the OS to create it.
Code: [Select]
(startapp
   (strcat
      "mkdir "
      <<YOUR FOLDER NAME>>
      ))

(startapp "mkdir c:\\TESTDIR")
Title: Re: Create project folders?
Post by: KewlToyZ on July 28, 2009, 09:05:09 AM
Most excellent help as always Gents!
I was looking at it and drawing a blank, thanks for pointing me in the right direction.

What had me stumbling is I could make bat files create directories and do xcopy, etc..
But how do I throw a directory structure into a current folder?
I think I would have to use the browse for folder and parse that selection result to a string then concatenate the string to my directory structure....
Hmmm ok I think it is getting clearer.

Let me see where I end up going with this.
I was looking to make project setups a little more robust.
Title: Re: Create project folders?
Post by: GDF on July 28, 2009, 10:41:04 AM
Gile

(CreateFolder "C://TEST") <- works fine


(CreateFolder "C://TEST//one//") <--Automation Error. Description was not provided.
The "TEST" folder has to exist first.


(CreateFolder "C://TEST")(CreateFolder "C://TEST//one//") <---this works
Title: Re: Create project folders?
Post by: GDF on July 28, 2009, 10:47:40 AM
Also using DosLib, you can create the folder structure and all files within it. Like from a server to your local drive.

C:\\
  Arch_Custom              folder
     Support                  folder, plus routine files copied from the server
     SaveFile                 folder
Title: Re: Create project folders?
Post by: taner on July 28, 2009, 08:15:44 PM
http://www.theswamp.org/index.php?topic=9441.msg121487#msg121487
Title: Re: Create project folders?
Post by: KewlToyZ on July 30, 2009, 08:59:58 AM
Thanks again Gentlemen ;-)