MJLM Posted June 2, 2021 Posted June 2, 2021 Is it possible to use ‘getfiled’ without displaying dialogue box? Intent is to save file quickly providing path, file name and no dialoge. Any suggestions appreciated. Quote
tombu Posted June 2, 2021 Posted June 2, 2021 Try setting FILEDIA to 0. FILEDIA (System Variable) Suppresses display of file navigation dialog boxes. Type:Integer Saved in:Registry Initial value:1 Set to 0 Does not display dialog boxes. You can still request a file dialog box to appear by entering a tilde (~) in response to the Command prompt. Set to 1 Displays dialog boxes. However, if a script is active, an ordinary prompt is displayed. Prompts are also displayed if an AutoLISP or ObjectARX™ program is active. (Not applicable to AutoCAD LT.) Note: Execution of scripts may temporarily hide the file navigation dialog boxes. 1 Quote
MJLM Posted June 2, 2021 Author Posted June 2, 2021 Thanks but it does not appear to be working. When running my routine with 'getfiled', the dialog box still pops up. The syntax I 'm using is as follows (setq DN (getvar "dwgname")) (setq DNLen (strlen DN)) (setq FN (getfiled "Save As: " (strcat (getenv "UserProfile") "\\Desktop\\" (substr DN 1 (- DNLen 4)) "_" (itoa g_pneti_file_idx)) "shc" 3)) Quote
tombu Posted June 2, 2021 Posted June 2, 2021 Maybe something here: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724421#M347479 Quote
MJLM Posted June 3, 2021 Author Posted June 3, 2021 Thanks again but I think these links talk about saving Autocad (dwg) files. Maybe I was not clear enough that I am interested in saving an ascii file containing data from the model through a Lisp routine and specifically by using the 'getfiled' command with a custom extension. Because I export multiple variations of data (i.e. files) in multiple times, clicking ok everytime for the 'save as' dialog box is tedious. So I was wondering if this dialog box was possible to be suppressed since providing path and file name makes it unnecessary. Quote
mhupp Posted June 3, 2021 Posted June 3, 2021 (edited) 2 hours ago, MJLM said: I am interested in saving an ascii file containing data from the model through a Lisp routine and specifically by using the 'getfiled' command with a custom extension. Because I export multiple variations of data (i.e. files) in multiple times, clicking ok everytime for the 'save as' dialog box is tedious. So I was wondering if this dialog box was possible to be suppressed since providing path and file name makes it unnecessary. maybe this will help Reading up on getfiled "32 (bit 5) If this bit is set and bit 0 is set (indicating that a new file is being specified), users will not be warned if they are about to overwrite an existing file. The alert box to warn users that a file of the same name already exists will not be displayed; the old file will just be replaced." Edited June 3, 2021 by mhupp 1 Quote
MJLM Posted June 3, 2021 Author Posted June 3, 2021 (edited) Thanks. I found this article through some googling I did myself but couldn't make it work no matter what flags I use. I 'm quite convinced so far that suppressing dialog boxes through lisp routines is not possible. Edited June 3, 2021 by MJLM Quote
dan20047 Posted June 3, 2021 Posted June 3, 2021 It seems a contradiction to not want a dialog box when using the getfiled command, which explicitly is for calling a dialog? Why not just use getstring? 1 Quote
MJLM Posted June 3, 2021 Author Posted June 3, 2021 getstring? would this command create a file on hard drive for me? Quote
dan20047 Posted June 3, 2021 Posted June 3, 2021 (edited) if you are writing ascii data, you need to open a file, write the data, then close it https://www.afralisp.net/autolisp/tutorials/file-handling.php if you are just saving a dwg to a new name, then use command SAVEAS Edited June 3, 2021 by dan20047 1 Quote
BIGAL Posted June 3, 2021 Posted June 3, 2021 (edited) You have not commented where are you saving the file to, its easy to do stuff like make a directory under current dwg location, use dwgname+date and so on. If you explain more then a better solution will be provided. Without using getfile can check if file exists. Do read write append. Edited June 3, 2021 by BIGAL Quote
MJLM Posted June 4, 2021 Author Posted June 4, 2021 (edited) My Lisp program extracts various data from a model (dwg file). Extracting here meant as creating ascii files with a custom extension provided by me in the getfiled command. One file is written per run. The program asks what kind of data and the user selects appropriately. The files are written always on the desktop and they are to be imported by an other program right after all runs are completed. So the life span of these ascii files is very short actually. The path is provided by the user in the lisp code and the file names are getting an index to avoid common names. So what I am trying to do is to avoid pressing 'enter' every time on the dialog box to dismiss it since with path and name it's unnecessary. The idea in the background is to use eventually a repeat procedure to eliminate the user seating in from of the computer for just clicking the 'enter' for the dialogue box. In case someone is wondering why not extract all data one time only, it cannot work like that. The importing I am doing on the other software woks only with specific data per file. Here is the code again with just a bit for more information (setq g_pneti_file_idx 0) (defun function (/...) (setq g_pneti_file_idx (1+ g_pneti_file_idx)) (setq DN (getvar "dwgname")) (setq DNLen (strlen DN) (setq FN (getfiled "Save As: " (strcat (getenv "UserProfile") "\\Desktop\\" (substr DN 1 (- DNLen 4)) "_" (itoa g_pneti_file_idx)) "shc" 3)) (setq FIL (open FN "w")) ... write stuff (close FIL) ) I can't explain better than that. Edited June 4, 2021 by MJLM Quote
mhupp Posted June 4, 2021 Posted June 4, 2021 (edited) like @dan20047 said getfiled is used to get a file path by prompting the user to pick a location. It isn't used in creating said file. I added ldata to save the variable idx and allow it to persist between commands and even when the drawing is saved and reopened. User will see this outputted to the command prompt C:\Users\UserName\Desktop\Drawing1_#.shc File Created (defun function (/ idx DN F) (vl-load-com) ;needed with any vla or vlax commands (setq idx (vlax-ldata-get "g_pneti" "File")) ;checks for ldata and sets the variable (if (= idx nil) (setq idx 0)) ; if varable is still nil sets it to 0 (setq idx (1+ idx)) (setq DN (vl-filename-base (getvar 'dwgname))) (setq F (open (strcat (getenv "UserProfile") "\\Desktop\\" DN "_" (itoa idx)".shc") "w")) (princ "Wright Stuff to file in same line\n" F) (princ "Next line \n" F) ;and so on (close F) (prompt (strcat"\n" (getenv "UserProfile") "\\Desktop\\" DN "_" (itoa idx)".shc File Created")) (vlax-ldata-put "g_pneti" "File" idx) ;save variable to ldata persists in drawing when saved. (princ) ) --- Edit Please note if you have 2 drawings named the same their is a possibility of overwriting the shc data if you leave it on your desktop. ---Edit 2 You could use "a" instead of "w" and have everything in one shc file. split it up with some princ between the data output so its easier to see. (princ "\n" fp) (princ "==============================================================" fp) (princ (strcat "Output " (itoa idx)) so it would show up like ============================================================== Output 1 data ... ============================================================== Output 2 more data Edited June 4, 2021 by mhupp forgot (vl-load-com) and errors note 1 Quote
MJLM Posted June 4, 2021 Author Posted June 4, 2021 Thanks a lot! That actually worked. I didn't new this could work without getfiled. 3 hours ago, mhupp said: Quote
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.