Search the Community
Showing results for tags 'directory'.
-
I'm using Lee Mac's great DirectoryFiles routine (copied below) to get a list of files in a given root directory. I'd like to stop the recursion prematurely and return nil if there are over 100 files in the list, but the recursion, mapcars, and lambdas are a bit above my head. Any help would be appreciated! ;; Directory Files - Lee Mac ;; Retrieves all files of a specified filetype residing in a directory (and subdirectories) ;; dir - [str] Root directory for which to return filenames ;; typ - [str] Optional filetype filter (DOS pattern) ;; sub - [bol] If T, subdirectories of the root directory are included ;; Returns: [lst] List of files matching the filetype criteria, else nil if none are found (defun LM:directoryfiles ( dir typ sub ) (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir))) (append (mapcar '(lambda ( x ) (strcat dir "\\" x)) (vl-directory-files dir typ 1)) (if sub (apply 'append (mapcar '(lambda ( x ) (if (not (wcmatch x "`.,`.`.")) (LM:directoryfiles (strcat dir "\\" x) typ sub) ) ) (vl-directory-files dir nil -1) ) ) ) ) )
-
Hi, is there a way to save my drawing with its name in a directory by using a Attribute value. Example: Drawingname: test.dwg blockname: TitleBlock Attribute: SF:WE Attribute-Value: test2 And it should save the drawing in: C:drawing/test drawing/(attribute-value)/... but it should be in a dialogbox, so i can choose the specific subfolder the direcotry up to the attribute-value is fix.
-
Error: bad argument value: string position out of range 17
TimG posted a topic in AutoLISP, Visual LISP & DCL
I have been having problems loading a lisp that has previously worked, without a problem for years, but now throws a message "Error: bad argument value: string position out of range 17". The lisp is loaded on opening of each drawing in the acaddoc.lsp, which has not changed. It is supposed to open a csv and update blocks. From what I can tell, it seems as though AutoCAD cant find the csv file in the Working Directory. (When opening a drawing with the lisp loaded in acaddoc.lsp specifying the name via findfile "name.csv") When I load the lisp through APPLOAD and manually select the file, via getfiled, it works. (findfile Nil) The Name of the csv has not changed in the acaddoc.lsp and the file is definitely in the same folder as the opened drawing. So my questions are, Is there any Variable in AutoCAD (Map 3d 2016) that could have changed to cause this? Is it a bug? Are there methods of finding the specified file in the same directory, (as the opened drawing), other than findfile? vla-get-FoundPath perhaps? How can I debug using VLISP? I tried (VL-BT) and get this; Backtrace: [0.19] (VL-BT) [1.15] (#) [2.12] (# "(vl-bt)" T #) :CALLBACK-ENTRY.6 (:CALLBACK-ENTRY) :ARQ-SUBR-CALLBACK.3 (nil 0) nil I'm not sure what it means? It's the first time I've used VLISP and only have a basic knowledge of VBA through a TAFE course, which was really more about VBS. At this stage I'm not sure if its a setting or AutoCAD is not looking in the right place? I have tried resetting autocad to default which didn't work, then I reinstalled autocad, which also didn't work. Then I updated to windows 10 just to see if some setting was changed or broken. None of those steps worked. I had been playing around with excel,( and had improved the spreadsheet which output the csv to also put out a xlsx, for a Data Link), in the previous weeks, which gave me the possibility that I had unwittingly changed a setting somewhere. The excel spreadsheet had worked with the lisp for at least 2 weeks before the error started to occur. One other thing to mention is that when excel is trying to save the csv and autocad is reading it,( has it open maybe? through the manual loading of it through the lisp), it comes up with an error 1004 or something. This happened to a co-worker who tried to debug it, and we tried alternate ways of saving the csv. After that moment the problems started. We tried the original untouched excel spreadsheet, acaddoc.lsp and method like we always had done, but now the error always occurs. Please, are there any suggestions? -
Lisp to create numbered folders based on selection
benhubel posted a topic in AutoLISP, Visual LISP & DCL
I have some drawings which contain hundreds of numbers (example: 1-218b), each of which is on geometry which will be written as a block into its own folder. I am trying to write a Lisp that will create all of the folders based on the selected text. I have found a few posts about writing a directory, but it's all super confusing to me. General routine process: 1. Get selected text objects 2. Prompt for directory to create new folders in 3. Create a folder for each selected text object, named based on the text It's ok to assume that the text is already selected when the Lisp starts. If no text is selected, I'd just send an error message to the console and end the routine. It's preferable that the directory prompt is GUI based so that I can navigate to the directory, but I am absolutely clueless here. If needed, I can just copy and paste the directory path into the console. The routine doesn't have to work with MText. The files contain only single line text. If I can get any code working, I'll post it, but I think it's going to take a good long while. -
Seeking template name and path of NEW drawing (not QNEWed)
Ahankhah posted a topic in AutoLISP, Visual LISP & DCL
Hi everybody, as I requested in another thread (Finding template of new drawing), I am seeking a way to find out the name and directory of the template file which is used for NEW drawing. I tested all ways mentioned in the thread, with no success (shown as follow) (getenv "General\\LastTemplate") (getenv "LastTemplate") (vla-get-TemplateDWGPath (vla-get-Files (vla-get-Preferences (vlax-get-acad-object)))) Indeed the returned name and path refers to Qnew template. I appreciate any help- 11 replies
-
- qnew
- new command
-
(and 2 more)
Tagged with:
-
AutoLISP code needed to remove directories (folders)
Ahankhah posted a topic in AutoLISP, Visual LISP & DCL
:)Hello everyone, I need to romove some empty directories via autolisp code. Is there any way? Any help is appreciated.- 2 replies
-
- directory
- directories
-
(and 1 more)
Tagged with: