Author Topic: xref reactor question  (Read 2650 times)

0 Members and 1 Guest are viewing this topic.

EagerToLearnCad

  • Guest
xref reactor question
« 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)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: xref reactor question
« Reply #1 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..")
    )
)
Tim

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

Please think about donating if this post helped you.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: xref reactor question
« Reply #2 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.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

EagerToLearnCad

  • Guest
Re: xref reactor question
« Reply #3 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: xref reactor question
« Reply #4 on: May 08, 2009, 10:53:29 AM »
You're welcome.
Tim

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

Please think about donating if this post helped you.