0 Members and 1 Guest are viewing this topic.
I am so lost now...I managed to incorporate Johns code and have the pop-up populated with the current filename but something is still not right.I type the new filename in the dialog, hit enter. The new filename appears on the command line, and I must hit enter again.Then I end up with a file called ".dwg.dwg" Can you please help--->%
Here is a version using powershell to create a saveFileDialog.It falls back on getfiled when something doesn't work.I should have spent less time on this, but I got a bit obsessed with getting a resizable file dialog.
Here is a complete code that should work. Although, there are some other areas of the code which I think should be corrected but I do not have the time at the moment, and this should work fine for now.
Quote from: CraigP on December 20, 2023, 08:43:39 PMI am so lost now...I managed to incorporate Johns code and have the pop-up populated with the current filename but something is still not right.I type the new filename in the dialog, hit enter. The new filename appears on the command line, and I must hit enter again.Then I end up with a file called ".dwg.dwg" Can you please help--->% You are very close. The line you had wrong was: (setq nDwgName (getstring 1 (getstring-dlg (strcase (acet-filename-ext-remove (getvar 'DWGNAME)))))it should be: (setq nDwgName (getstring-dlg (strcase (acet-filename-ext-remove (getvar 'DWGNAME))))Here is a complete code that should work. Although, there are some other areas of the code which I think should be corrected but I do not have the time at the moment, and this should work fine for now.Code - Auto/Visual Lisp: [Select];;;COMMAND: RENDWG;;;FUNCTION: Save current drawing as a new one with user specified name and;;; delete original drawing if successful.;;;NOTES: Current drawing should have been saved prior to using this command.;;;By: Kelie Feng, April 2006.;;;Revised C.Potter December 2023. (https://www.theswamp.org/index.php?topic=9696.0);;; (defun GetString-dlg (str / dcl_id fn fo) (setq fn (vl-filename-mktemp "" "" ".dcl")) (setq fo (open fn "w")) (setq ValueStr (strcat "value = \"" str "\";")) (write-line "stringdlg : dialog { label = \"Enter New Filename\";" fo ) (write-line ": edit_box { label = \"\"; edit_width = 30; key = \"stringdlg\"; is_default = true; " fo ) (write-line ValueStr fo) (write-line "}" fo) (write-line ": row { alignment = centered; fixed_width = true; : button { label = \"OK\"; key = \"dcl_accept\"; width = 10; allow_accept = true; } } }" fo ) (close fo) (setq dcl_id (load_dialog fn)) (new_dialog "stringdlg" dcl_id) (action_tile "stringdlg" "(setq str $value)(done_dialog)") (start_dialog) (unload_dialog dcl_id) str)(defun C:RENDWG1 (/ *ERROR* app saveAsType doc oPath oDwgName dir nDwgName nPath) (setq app (vlax-get-acad-object) saveAsType (vla-get-saveastype (vla-get-opensave (vla-get-preferences app) ) ) doc (vla-get-activedocument app) oPath (vla-get-fullname doc) oDwgName (vla-get-name doc) dir (getvar "DWGPREFIX") ) (setq nDwgName (getstring-dlg (strcase (acet-filename-ext-remove (getvar 'DWGNAME)))) nPath (strcat dir nDwgName ".dwg") ) (if (or (not (findfile nPath)) (KF:Yes? nil (strcat "File \"" nDwgName ".dwg\"" " exists. Overwrite?") ) ) (if (not (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () (vla-saveas doc nPath saveAsType) (vl-file-delete oPath) ) ) ) ) ) (prompt "\nDone.") (prompt "\nRename/delete failed.") ) ) (princ) ) (defun KF:Yes? (default msg / input) (initget "Yes No") (setq input (getkword (strcat "\n" msg " [Yes/No] <" (if default "Y" "N" ) ">: " ) ) ) (cond ((= input "Yes") t) ((= input "No") nil) (t default) )) (princ)
Quote from: dexus on January 05, 2024, 06:19:20 AMHere is a version using powershell to create a saveFileDialog.It falls back on getfiled when something doesn't work.I should have spent less time on this, but I got a bit obsessed with getting a resizable file dialog.Was not able to find copies of LM:acobj or LM:acdoc called in your program.Can you share these?Steve
Quote from: stevej on January 06, 2024, 09:35:15 PMQuote from: dexus on January 05, 2024, 06:19:20 AMHere is a version using powershell to create a saveFileDialog.It falls back on getfiled when something doesn't work.I should have spent less time on this, but I got a bit obsessed with getting a resizable file dialog.Was not able to find copies of LM:acobj or LM:acdoc called in your program.Can you share these?SteveOops, I removed the dependencies. Could you give it another try?