Hi all.
I have this code to insert references, only selecting the file and the insertion point.
The problem I have is that the command does not work the first time I run it when I start new drawings or start the autocad.
What's going on?
(defun c:AT (/) (initdia) (command "_.-XREF" "_Attach" "_None" MYPOINT "") (setq MYPOINT (getpoint "\nselect an insertion point")) (while (> (getvar "CMDACTIVE") 0) (command "")) (princ) )
@jjorovi wrote:
Hi all.
I have this code to insert references, only selecting the file and the insertion point.
The problem I have is that the command does not work the first time I run it when I start new drawings or start the autocad.
What's going on?
(defun c:AT (/) (initdia) (command "_.-XREF" "_Attach" "_None" MYPOINT "") (setq MYPOINT (getpoint "\nselect an insertion point")) (while (> (getvar "CMDACTIVE") 0) (command "")) (princ) )
You have it trying to use the MYPOINT variable before it has been set. And you're not going to be able to feed in the options such as Attach and the location from a (command) function if you're in the dialog box. Try getting that point first, and a file name first also [see the (getfiled) function], and then, without the (initdia), feed them into an Xref command.
Something like this?
(defun c:AT () (setq FILEN (getfiled "Select File" "C:/" "dwg" 8)) (setq MYPOINT (getpoint "\nselect an insertion point")) (command "_.-XREF" "_Attach" FILEN MYPOINT "") (while (> (getvar "CMDACTIVE") 0) (command "")) (princ) )
How I can go back to the previous folder address where I selected the last reference?
If I understood correctly, something like this perhaps.
(defun c:AT (/ BASE FILEN MYPOINT) (setq BASE "c:/") (while (and (setq FILEN (getfiled "Select File" BASE "dwg" 8)) (setq MYPOINT (getpoint "\nselect an insertion point")) );; and (command "_.-XREF" "_Attach" FILEN MYPOINT "" "" "") (setq BASE (strcat (vl-filename-directory FILEN) "\\")) );; while (princ) );; AT
HTH
Henrique