Author Topic: Capture Project Navigator Command for Drag/Drop for Xrefing  (Read 1654 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
So I'm finally getting into the Project Navigator and one of the things I'd like to do is capture the event when you drag and drop a file from the Views tab into a drawing which then attaches that file as an xref.  I'd like to be able to automatically put the xref onto a company standard xref layer and lock it.

Any thoughts?  Anyone?!?

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Capture Project Navigator Command for Drag/Drop for Xrefing
« Reply #1 on: May 09, 2008, 10:22:58 AM »
Matt,
Unfortunately dragging a file from the Project Navigator throws no trappable command.  I use a combination of the Xref Reactor and Modelspace Reactor.  The :VLR-beginAttach fires when the Xref is about to be attached, so I set my XREF layer current.  I couldn't get the :VLR-endAttach to work to re-set the clayer - the database wasn't "released" yet(?) so it wouldn't re-set clayer.  I had to go to the Modelspace Reactor to check when things are attached in modelspace (we rarely attach xrefs in pspace) <edit> it works on paper space too</edit>.  It's a kludge I know - but it works.  Let me know if you find out a better way:

Code: [Select]
;;; ;
;;; XREF Reactor ;
;;; Uses the modelspace reactor to re-set clayer ;
;;; ;

;;; Xref Call Back functions ;

;;; Begin Attach ;
(defun jb:beginAttach  (reactor vla-object /)
  (if (not (tblsearch "layer" "XREF"))(vla-add (vla-get-layers (vla-get-activedocument(vlax-get-acad-object))) "XREF"))
  (setq jb%XrefAttach T)
  (if (tblsearch "layer" "XREF")(jb:setclayer "XREF" T))
  (princ)
  )


;;; Construct Xref Reactor ;
(defun jb::ConstructXrefReactor  (/)
  (if (= (type *jbXrefReactor*) 'VLR-Xref-Reactor)
    (progn (vlr-remove *jbXrefReactor*)
   (setq *jbXrefReactor* nil)))
  (if (/= (type *jbXrefReactor*) 'VLR-Xref-Reactor)
    (setq *jbXrefReactor*
   (VLR-Xref-Reactor
     "jbTools Xref Reactor" ; Data associated with the editor reactor
     ;; call backs
     '
      ((:VLR-beginAttach . jb:beginAttach)
               )) ;_ end of vlr-xref-reactor
  ))
  (if (not (vlr-added-p *jbXrefReactor*))
    (progn (vlr-add *jbXrefReactor*)
   (vlr-set-notification *jbXrefReactor* 'active-document-only)))
  (princ))


;;; load reactor ;


(if jb::ConstructXrefReactor
  (jb::ConstructXrefReactor))



;;; ;
;;; ModelSpace Reactor ;
;;; Uses the modelspace reactor to re-set clayer ;
;;; ;



(defun jb::StartResetReactor( / )
(if *jbMSReactor* (vlr-remove *jbMSReactor*))
(setq *jbMSReactor* (vlr-object-reactor (list (vla-get-modelspace (vla-get-activedocument(vlax-get-acad-object)))) nil '((:vlr-objectClosed . jb:resetXrefLayer))))
(if *jbPSReactor* (vlr-remove *jbPSReactor*))
(setq *jbPSReactor* (vlr-object-reactor (list (vla-get-paperspace (vla-get-activedocument(vlax-get-acad-object)))) nil '((:vlr-objectClosed . jb:resetXrefLayer))))

  )

(defun jb:resetXrefLayer (owner reactor_object reactor_list  /)
  (if jb%XrefAttach
    (progn
      (if dcl_HideErrorMsgBox
   (if (dcl_Form_IsActive jb001_00)
     (c:jb001_00_Refresh_OnClicked))
         )
      (jb:resetclayer)
      (setq jb%XrefAttach nil)))
 
  )

;;; load reactor ;


(if jb::StartResetReactor
  (jb::StartResetReactor))
« Last Edit: May 09, 2008, 11:55:30 AM by jbuzbee »
James Buzbee
Windows 8

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Capture Project Navigator Command for Drag/Drop for Xrefing
« Reply #2 on: May 09, 2008, 11:22:58 AM »
Would this work for you?

[ http://www.theswamp.org/index.php?topic=15557.0 ]

It should fire no matter what space you attach an xref to.  I don't use the project navigator, so I didn't know how to test it out.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.