@andreas7ZYXQ wrote:
....
I would like to start my routine with save as in a subfolder where the curent drawings is saved.
after this routine i want to add various things so it has to be "opened" as i[t] normally does when pressing save as in the file tab...
....
I assume you mean a subfolder under the one in which the current drawing is located, not the same subfolder in which it is, as @Shneuph appears to have assumed. There's no need to have to spell out a subfolder name, nor check whether it exists [whether because it hasn't been made yet or you mis-typed it]. You can do this:
(defun C:DOSTUFF (/ some local variables)
(... do some initial stuff ...)
(initdia); INITiate the DIAlog box for the following command
(command "_.saveas"); do all you need to do in the dialog box
(... do more stuff ...)
(... do more other stuff ...)
(princ)
); defun
The (initdia) is needed because without it, commands called in a (command) function use the command-line version. The all you need to do part includes the options of picking on an existing subfolder if there is one [no risk of typing its name incorrectly], just entering a new drawing name if you want it in the same folder the starting drawing is in, right-clicking in the list of drawings and picking New > Folder if you need to make one that doesn't exist yet, navigating to somewhere entirely unrelated if that's what you need, etc., etc. Since it's operating through the dialog box, there's no need to do the wait-for-input-until-the-command-is-done thing that you typically do with a command in which you don't know the amount of inputs the User will need to provide, in command-line mode.
I wasn't sure this approach would work, because I had always heard that an AutoLisp routine can't start in one drawing and continue in another, but I tried it, and in this case it does, presumably because SAVEAS moves you into the new drawing, and the starting one doesn't remain active. [I think an example of what wouldn't work would be with an OPEN command, in which case the drawing you start the routine in is still active, but I haven't tested the theory]. I did the following as a completely arbitrary test:
(defun C:TEST ()
(initdia)
(command "_.saveas")
(command "_.circle" (getvar 'viewctr) 10)
(command "_.move" "_last" "" "0,5" "")
)
and sure enough, when I ran the TEST command, I got to save a new drawing, was taken into it, and it did draw a 10-radius Circle in the middle of the screen, and Moved it up 5 units. So it will take you into the new drawing and continue with your "add various things" part.
Kent Cooper, AIA