Jump to content

xattach without dialog box


rcb007

Recommended Posts

Is it possible to use the (command "_.xattach" ) without the dialog box? 

 

Is there a way to activate the command and the user selects the files to be xref'd and automatically brings them in 0,0 with an overlay.

 

Thank you for the help.

Link to comment
Share on other sites

51 minutes ago, rcb007 said:

Is it possible to use the (command "_.xattach" ) without the dialog box? 

Set FILEDIA to 0.

Edited by ronjonp
Link to comment
Share on other sites

I need to edit my original post. How about for selecting multiple dwgs at once?

 

Sorry about that.

Link to comment
Share on other sites

1 hour ago, rcb007 said:

How about for selecting multiple dwgs at once?

 

Untested Lightly Tested.

 

(defun C:Multi-OVERLAY (/ path fp lst Reflst ref)
  (setq path (strcat (getvar 'DWGPREFIX) "\\Pick List to import")
        fp (getfiled "Reference File List:" path "" 33)
        path (vl-filename-directory fp)
        lst (vl-directory-files path "*.dwg" 1)
        ;lst (append lst (vl-directory-files path "*.dxf" 1)) ;if you want to see other types of files
        lst (vl-sort lst '<)
  )
  (if (setq Reflst (AT:ListSelect (strcat (itoa (length lst)) " Reference(s) in Folder") "Pick Reference(s) to Insert Into Drawing" 30 60 "true" lst))
    (foreach ref Reflst
      (command "_.-XREF" "_Overlay" (strcat path "\\" ref) "_non" '(0.0 0.0 0.0) "" "" "")
    )
  )
  (princ)
)

;; List Select Dialog (Temp DCL list box selection, based on provided list)
;; title - list box title
;; label - label for list box
;; height - height of box
;; width - width of box
;; multi - selection method ["true": multiple, "false": single]
;; lst - list of strings to place in list box
;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite)
(defun AT:ListSelect (title label height width multi lst / fn fo d f)
  (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
  (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;")
                   (strcat ": list_box { label = \"" label "\";" "key = \"lst\";")
                   (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";")
                   (strcat "width = " (vl-princ-to-string width) ";")
                   (strcat "multiple_select = " multi "; } spacer; ok_cancel; }")
             )
    (write-line x fo)
  )
  (close fo)
  (new_dialog "list_select" (setq d (load_dialog fn)))
  (start_list "lst")
  (mapcar (function add_list) lst)
  (end_list)
  (setq item (set_tile "lst" "0"))
  (action_tile "lst" "(setq item $value)")
  (setq f (start_dialog))
  (unload_dialog d)
  (vl-file-delete fn)
  (if (= f 1)
    ((lambda (s / i s l)
       (while (setq i (vl-string-search " " s))
         (setq l (cons (nth (atoi (substr s 1 i)) lst) l))
         (setq s (substr s (+ 2 i)))
       )
       (reverse (cons (nth (atoi s) lst) l))
     )
      item
    )
  )
)

 

Edited by mhupp
Link to comment
Share on other sites

Why do you need a lisp to do this?

XATTACH will let you attach multiple files at once in a directory, and if you set XREFTYPE to 1 it will default to an overlay. All you're left with is the insertion point which defaults to '(0 0 0).

Link to comment
Share on other sites

Yes you are right. I did not know if you could bypass the attach external reference dialog box, to where once you select the files, it just come in.

Link to comment
Share on other sites

On 5/9/2022 at 12:03 PM, ronjonp said:

Set FILEDIA to 0.

Note. I just tested this: if you call XATTACH within a command subr i.e. (command "._XATTACH" ...) you do not need to set FILDIA to 0.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...