Irish Posted October 1, 2008 Share Posted October 1, 2008 Hi! new to the forum. I am learning lisp. Hopefully I can someday give back what I learn here with you guys and gals. The afralisp tutorial talks about using the dir command to make a list of drawings in a folder. Command: (command "dir" " /b *.* >temp.txt") first, How do I set dir to my corrent working directory? do I need to have a cmd window open? Second, how do I take the drawings temp.txt and open it 1 by 1. right now I am using the (command "filedia" "0") and then (command "open") but that does not work. Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 1, 2008 Share Posted October 1, 2008 To view the contents of a folder (used to be called a directory) the old DIR command was used. For example, to view the contents of the C:\AutoCAD directory one would type: dir c:\autocad You'll need the complete path to the files you want to see. For example, if your files were in a folder called 2008, under another folder called My Products the path would be: dir c:\myprojects\2008 If you have more than a screen full of files to view at a time you could use the /p switch to pause one screen at a time. Thus, you would have: dir c:\myprojects\2008 /p Just thinking. Would this work with any of the new operating systems like Vista or XP? It's been a long time since I used DOS commands. Maybe you would have to open a command window first now that I think about it. Quote Link to comment Share on other sites More sharing options...
Irish Posted October 1, 2008 Author Share Posted October 1, 2008 A drirectory... true. GUI Kid here It does work on a cmd window, but I do not know how to make it work on autocad. Quote Link to comment Share on other sites More sharing options...
Biscuits Posted October 1, 2008 Share Posted October 1, 2008 Welcome to the forum. You might try: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=17&lngWId=13 look for DIRTXT.LSP by Russel Steffy This routine lets you select the proper folder and prints a directory list to a notepad file. Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted October 1, 2008 Share Posted October 1, 2008 Just thinking. Would this work with any of the new operating systems like Vista or XP? It's been a long time since I used DOS commands. Maybe you would have to open a command window first now that I think about it. it does work with XP and Vista, I use this every day for writing scripts. I can useally write a script in under 3 minutes for any number of drawings, from 10 to 1000. I add some switchs to the command though. (which I will talk about in a minute) Open a command window (referred to as DOS from here on out) Change to the directory you wish to process using CD (change directory) ie CD H: would change to the H Drive (assuming it exists) DOS should say H:> at which point you could continure changing to subfolders like CD MyProjects followed by CD 2008 or instead of the 2 steps, CD MyProjects\2008 as a 1 step. DOS should read H:\MyProjects\2008> at which point you can now create the txt file. At this point, you must decide how you want to access the file ie Are you making a scr file, are you making a data file that other code will open and process the files within, or what have you. Assuming you want to make a script file, type DIR *.dwg /b/s > filename.scr The /B strips the file name to BARE mode which is only the file name and extension. The /S adds the subdirectory to the filename which is good for script files as you have the full path right there. The > is a redirector whcih tells DOS to redirect the normal screen input to somewhere else, in this case a file. Other redirects could be LPT1, whcih would make a print of the info (assuming you have a LPT1 connected) Now the fun begins. Do a search and replace to make your script and your done Quote Link to comment Share on other sites More sharing options...
Irish Posted October 1, 2008 Author Share Posted October 1, 2008 yes, but how do you do this in autocad? and more impotantly, how do you open a drawing from autocad?! Quote Link to comment Share on other sites More sharing options...
CAB Posted October 1, 2008 Share Posted October 1, 2008 Look here to open a file http://cadtutor.net/forum/showthread.php?t=26732&highlight=open+file To get a file use Prompts the user for a file name with the standard AutoCAD file dialog box, and returns that file name(getfiled title default ext flags) The getfiled function displays a dialog box containing a list of available files of a specified extension type. You can use this dialog box to browse through different drives and directories, select an existing file, or specify the name of a new file. Quote Link to comment Share on other sites More sharing options...
ASMI Posted October 1, 2008 Share Posted October 1, 2008 AutoLISP has standard function VL-DIRECTORY-FILES which return list of files inside directory specified and filename wildcard pattern specified. Quote Link to comment Share on other sites More sharing options...
Irish Posted October 1, 2008 Author Share Posted October 1, 2008 (defun C:GETDIR ( / ) ; (setq adwg ".dwg") (command "filedia" "0") (setq rpwf (vl-directory-files (GETVAR "DWGPREFIX") "*.dwg" 1)) (setq path (getvar "DWGPREFIX")) (foreach rfi rpwf (setq filec (strcat path rfi)) (vla-open (vla-get-documents (vla-get-application (vlax-get-acad-object)) ) filec) (getint "press enter") ) ) We kick butt! Thank you people! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.