Author Topic: Up DWGPROPS revsion on save / exit of drawing automatically  (Read 2205 times)

0 Members and 1 Guest are viewing this topic.

ROBBO

  • Bull Frog
  • Posts: 217
Up DWGPROPS revsion on save / exit of drawing automatically
« on: January 30, 2015, 11:18:57 AM »
Any help, as always appreciated. I am trying to add a routine to my start-up that would automatically update the dwgprops revision from the rev letter in the layout tab. I have tried, but struggling to get it to work.

This is what I have thus far:

Code - Auto/Visual Lisp: [Select]
  1. (defun sstrtcmdRev (calling-reactor sstrtcmdRevinfo / Rev)
  2.   (if (wcmatch (car sstrtcmdRevinfo) "*SAVE*")
  3.     (progn
  4. (defun updpRev (/ acsum Rev)
  5. (setq Rev (getvar "CTAB"))
  6. (setq acsum
  7.     (vla-get-summaryinfo
  8.         )
  9.       )
  10.     )
  11.   )
  12. )
  13.   (vla-get-revisionnumber acsum)
  14. (vla-put-revisionnumber acsum Rev)
  15. )

I have a similar lisp that works when the command is entered and works fine, but would like this to update automatically.

Many thanks in advance, Robbo.
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

CincyJeff

  • Newt
  • Posts: 89
Re: Up DWGPROPS revsion on save / exit of drawing automatically
« Reply #1 on: January 30, 2015, 12:01:28 PM »
I would think you could use a reactor to fire before the end command runs or you can redefine the end command to perform your function before closing.

ChrisCarlson

  • Guest
Re: Up DWGPROPS revsion on save / exit of drawing automatically
« Reply #2 on: January 30, 2015, 12:27:45 PM »
Where is the command that currently works? If you want it to run every time a drawing is opened, add the command to the end of your routine, and have the routine set to autoload

so something like this

Code: [Select]
(defun c:LevelUpLikeMario (/)
(princ)
)
(LevelUpLikeMario)

ROBBO

  • Bull Frog
  • Posts: 217
Re: Up DWGPROPS revsion on save / exit of drawing automatically
« Reply #3 on: February 02, 2015, 02:23:08 AM »
Where is the command that currently works? If you want it to run every time a drawing is opened, add the command to the end of your routine, and have the routine set to autoload

so something like this

Code: [Select]
(defun c:LevelUpLikeMario (/)
(princ)
)
(LevelUpLikeMario)

This is the routine/command to run on drawing start-up, but would prefer to have the command run when drawing is saved or on exit;

Code - Auto/Visual Lisp: [Select]
  1. (defun c:updpRev (/ acsum Rev)
  2. (setq Rev (getvar "CTAB"))
  3. (setq acsum
  4.     (vla-get-summaryinfo
  5.     )
  6. )
  7. (vla-get-revisionnumber acsum)
  8. (vla-put-revisionnumber acsum Rev)
  9. )
  10. (c:updpRev)
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Up DWGPROPS revsion on save / exit of drawing automatically
« Reply #4 on: February 02, 2015, 07:54:54 AM »
If I look at the code in the first post I notice some issues:
1.
When the command name matches "*SAVE*" you define a function without executing it.
2.
Lines 14 and 15 are outside the function updpRev.
3.
Line 14 is not necessary.

Using a :vlr-commandwillstart reactor you should be able to react to the SAVE and QSAVE commands. But I would not attempt to react to the QUIT command.

Code: [Select]
(if *myCommandReactor*
  (vlr-remove *myCommandReactor*)
)
(setq *myCommandReactor*
  (vlr-command-reactor nil '((:vlr-commandwillstart . sstrtcmdRev)))
)

(defun sstrtcmdRev (rea lst)
  (if (wcmatch (car lst) "*SAVE*") (updpRev))
)

(defun updpRev (/ acsum Rev)
  (setq Rev (getvar "CTAB"))
  (setq acsum
     (vla-get-summaryinfo
         (vla-get-activedocument (vlax-get-acad-object))
     )
  )
  (vla-put-revisionnumber acsum Rev)
)

ROBBO

  • Bull Frog
  • Posts: 217
Re: Up DWGPROPS revsion on save / exit of drawing automatically
« Reply #5 on: February 02, 2015, 08:06:17 AM »
If I look at the code in the first post I notice some issues:
1.
When the command name matches "*SAVE*" you define a function without executing it.
2.
Lines 14 and 15 are outside the function updpRev.
3.
Line 14 is not necessary.

Using a :vlr-commandwillstart reactor you should be able to react to the SAVE and QSAVE commands. But I would not attempt to react to the QUIT command.

Code: [Select]
(if *myCommandReactor*
  (vlr-remove *myCommandReactor*)
)
(setq *myCommandReactor*
  (vlr-command-reactor nil '((:vlr-commandwillstart . sstrtcmdRev)))
)

(defun sstrtcmdRev (rea lst)
  (if (wcmatch (car lst) "*SAVE*") (updpRev))
)

(defun updpRev (/ acsum Rev)
  (setq Rev (getvar "CTAB"))
  (setq acsum
     (vla-get-summaryinfo
         (vla-get-activedocument (vlax-get-acad-object))
     )
  )
  (vla-put-revisionnumber acsum Rev)
)

Thank you roy_043
The only thing to do with good advice is to pass it on.
It is never of any use to oneself.

Oscar Wilde
(1854-1900, Irish playwright, poet and writer)