TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: EagerToLearnCad on May 06, 2009, 01:37:11 PM

Title: xref reactor question
Post by: EagerToLearnCad on May 06, 2009, 01:37:11 PM
Anyone,

I want to remind people in my office to reload the all the xrefs they just unloaded
before they close the drawing.

I notice the commands "exporttoautocad" & "etransmit" cannot bind drawings
with xrefs that are unloaded.

Can somebody please fix this code, or what am I doing wrong. The alert box comes about four times.

(if (not *Xref-Unload*)
(setq *Xref-Unload*
   (vlr-Xref-reactor
      nil
      '((:VLR-xrefSubcommandUnloadItem . Alert-Unload))
        )
)
)

(defun Alert-Unload (react call-back /)
(Alert "Please Do Not Forget To Reload The Xref/s..")
)

(defun c:removexrefunload ()
(vlr-remove *Xref-Unload*)
(setq *Xref-Unload* nil)
)
Title: Re: xref reactor question
Post by: T.Willey on May 07, 2009, 05:29:48 PM
Quote from the help.

Quote
:VLR-xrefSubcommandUnloadItem
 2
 First parameter is an integer indicating the activity the UNLOAD is carrying out. Possible values are

0—BIND subcommand invoked.

2—xref with the indicated object ID is being bound.

3—xref with the indicated object ID was successfully bound.

4—BIND subcommand completed.

5—BIND operation is about to either terminate or fail to complete on the specified object ID.

6—BIND operation has either terminated or failed to complete on the specified object ID.

Second parameter is an integer containing the object ID of the xref being unloaded, or 0 if not applicable.
 

It seems that it goes though four stages with an unload.  My did them in order of; 0 2 3 4.  Maybe you can just check to see if it completed ( 4 ), and if so, then alert the user.  Seems to work for me.

Code: [Select]
(defun Alert-Unload (react call-back /)
(if (equal (car call-back) 4)
    (Alert "Please Do Not Forget To Reload The Xref/s..")
    )
)
Title: Re: xref reactor question
Post by: dgorsman on May 07, 2009, 06:56:44 PM
Try checking for a flag and calling (alert...) if it is not set, then setting the flag after the (alert...) so it only alerts once.  At some later stage in the process once all XREF processes have completed clear the flag.
Title: Re: xref reactor question
Post by: EagerToLearnCad on May 08, 2009, 08:26:38 AM
Tim,

Thank you. I learned more about "call backs" from the code you posted.

dgorsman,
Thanks. I like that idea. I'll use that approach next time.
Title: Re: xref reactor question
Post by: T.Willey on May 08, 2009, 10:53:29 AM
You're welcome.