Author Topic: OPEN only 4 drawings MAX.  (Read 2019 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
OPEN only 4 drawings MAX.
« on: January 05, 2005, 04:24:22 PM »
Ok, There is another one...

I there any variable to set, to make AutoCAD open only 4 drawing MAX ??

SDI mode can't do the job..

any help ?
Keep smile...

Rob_Kish

  • Guest
OPEN only 4 drawings MAX.
« Reply #1 on: January 05, 2005, 08:47:15 PM »
No system variable. Certainly the open command could be redefined; would help to have an idea what your goal is ... other than 'no more than four'.

Andrea

  • Water Moccasin
  • Posts: 2372
OPEN only 4 drawings MAX.
« Reply #2 on: January 06, 2005, 11:29:32 AM »
Quote from: Rob_Kish
No system variable. Certainly the open command could be redefined; would help to have an idea what your goal is ... other than 'no more than four'.


what do you think of this...


(defun c:nomore4 ()
(setq acadObject (vlax-get-acad-object))
(setq documents (vla-get-Documents acadObject))
(setq count (vla-get-Count documents))
(if (> count 4) (command "_close"))
(princ)
)
Keep smile...

Serge J. Gianolla

  • Guest
OPEN only 4 drawings MAX.
« Reply #3 on: January 09, 2005, 05:42:18 PM »
Ciao Andrea,

I've given some thought to your query. At first, it appeared that :vlr-beginDwgOpen, or FileOpen... would be the go; unfortunately these reactors do not react! If memory serves me well, I think Daron had trouble with them? Even if they'd work, there were always the possibilities that your users would open a DXF [not trapped by beginDwgOpen] or double-clicking a dwg from explorer! So, went to trap OPEN command and checking number of documents. In this code, if more than 3 drawings are open, I was able to cancel commands such as EXPLODE, ERASE - You can play with cancelling MOVE, COPY... - but cannot abort the call on OPEN!! Can someone explain why, or better still take it from there?

Code: [Select]
(vl-load-com)
(defun CancelOpen (calling-reactor commandInfo / iNum sComm )
  (setq sComm (car CommandInfo))
  (if (equal (getvar "SDI") 1)
    (setq iNum 1)
    (setq ;If in MDI mode
      iNum (vla-get-count (vla-get-documents (vlax-get-acad-object))) ;get number of dwgs currently open
    )
  ) ;_ EndOf if
  (if (and (> iNum 3) (wcmatch sComm "ERASE,EXPLODE,OPEN"))
    (progn
      (vla-sendcommand
(vlax-get (vlax-get-acad-object) "activedocument")
"(vl-cmdf) "
      )
    )
  )
)

(if *My_Reactor*
  (vlr-remove *My_Reactor*) ;Avoid multiple loading
)
(setq *My_Reactor*
       (vlr-editor-reactor ;or vlr-Command-reactor
nil
'(
  (:vlr-commandWillStart . CancelOpen)
 )
       )
)

As the routine stands now, it is gonna work only if from drawing A [where the code would be loaded], one opens B, C, D... but not if you open from A B, then from B open C... unless you load routine for each drawing. The cancelling of the commands only happens when using the verb-->nouns  conventional way for AutoCAD to work - starting the command then selecting objects. Provision was not made for the reverse approach, my intention was to catch OPEN then disable it, so went along to test on other commands to see if they'd be cancelled when I realised it did not work on OPEN. Did not bother to make a Defun, is active upon loading!

Andrea

  • Water Moccasin
  • Posts: 2372
OPEN only 4 drawings MAX.
« Reply #4 on: January 10, 2005, 11:14:42 AM »
Serge,...

the last code posted comes from
Serge Camire...(AutoDESK)

I don't undertsand all reactor command...sorry. :cry:

je peux lui demander si tu veux..;-)
Keep smile...

Serge J. Gianolla

  • Guest
OPEN only 4 drawings MAX.
« Reply #5 on: January 10, 2005, 05:08:57 PM »
Tu m'as perdu! Je ne sais pas de quel code tu parles - celui de Serge Camire? Mais celui du dessus, c'est de moi; pour essayer de resoudre ton probleme pose "ne pas ouvrir plus de 4 plans."  Par-contre, oui bonne idee, si tu connais qlq'un a Autodesk qui peut expliquer pourquoi je peux annuler une commande telle que DECOMPOSE, EFFACE... mais pas SAVE ou OPEN? Je suis preneur. A+.
P.S: Si tu comprends pas ce que ma routine fait, laisse moi savoir je t'enverrai les explics en francais.

Serge J. Gianolla

  • Guest
OPEN only 4 drawings MAX.
« Reply #6 on: January 11, 2005, 11:22:10 PM »
So, it appears no one is able to explain why one can cancel the draw or editing commands, but not a call on SAVE or OPEN! I find this hard to believe  :o someone always has an answer  :wink: Seriously; help