Reactor for open and close dwg

Reactor for open and close dwg

DGRL
Advisor Advisor
1,236 Views
3 Replies
Message 1 of 4

Reactor for open and close dwg

DGRL
Advisor
Advisor

Dear forum members,

 

I have an reactor that will fire an lsp when user presses SAVE or QSAVE

I googles unsuccessfully my ass off to find a way to change this one into endopen en close of dwg


Instead of running up the lsp when a user presses save I want it to run when an dwg is opened or when it will close

 

This is the code now

 

(vlr-command-reactor
  nil
  '((:vlr-commandEnded . endCommand))
)

(defun endCommand (calling-reactor endcommandInfo / thecommandend)
  (setq thecommandend (nth 0 endcommandInfo))
  (cond
    ((= thecommandend "QSAVE") (qs:backup))
    ((= thecommandend "SAVE") (qs:backup))
  )
)

 

Best regards

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
1,237 Views
3 Replies
Replies (3)
Message 2 of 4

DannyNL
Advisor
Advisor

In that case you cannot use a command reactor as this will only react to commands and not specific events.

To create a reactor with your specifications you should probably use a vlr-dwg-reactor,

 

See: http://help.autodesk.com/view/ACD/2018/ENU/?guid=GUID-82B7F0D1-02AD-4463-A8A3-BF87EFCC83A4

Message 3 of 4

Ranjit_Singh
Advisor
Advisor

You can setup reactor to process certain code when a drawing is opened. However, this will execute commands in the original document and not in the newly opened file. To take action on the new opened document use the S::STARTUP function.

For document close, you are using commandended reactor. There is nothing left to do after the commandended event for a dwg close. AutoCAD will simply release lock on file. You may want to use commandwillstart event and do whatever processes you need. If the command is cancelled then detect that with a commandcancelled event and undo all of those processes (or not depending on your logic).

0 Likes
Message 4 of 4

john.uhden
Mentor
Mentor

vlr-dwg-reactor is definitely correct.

You can use (strcase (getvar "cmdnames")) to find out what command triggered it.

John F. Uhden

0 Likes