Author Topic: How to use vla-close ?  (Read 632 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 725
How to use vla-close ?
« on: March 28, 2023, 12:22:39 PM »
I apologize if the question is perhaps too stupid. . .
but I need, with vlisp, to close an opened dwg file by another (active) dwg file. . .
how you do it ?

How to use vla-close ?

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: How to use vla-close ?
« Reply #1 on: March 28, 2023, 12:34:37 PM »
You mean command : CLOSE ?
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: How to use vla-close ?
« Reply #2 on: March 28, 2023, 12:47:40 PM »
Untested...

Code - Auto/Visual Lisp: [Select]
  1. (defun closeallbutactive ( / cad )
  2.  
  3.  
  4.     (if (not (equal (vla-get-activedocument cad) doc))
  5.       (vla-close doc)
  6.     )
  7.   )
  8.   (princ)
  9. )
  10.  

HTH.
M.R.
« Last Edit: March 28, 2023, 12:57:17 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: How to use vla-close ?
« Reply #3 on: March 28, 2023, 12:55:24 PM »
It says :  Automation Error. Drawing is busy.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: How to use vla-close ?
« Reply #4 on: March 28, 2023, 12:58:19 PM »
It says :  Automation Error. Drawing is busy.

It was because of line 6.
should be (equal) instead of (eq) that was before I altered function...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: How to use vla-close ?
« Reply #5 on: March 28, 2023, 01:21:45 PM »
Marko, thank you very much!
It works !
Today I lost a couple of hours,
and I don't understand (now) why I didn't succeed !
Now it seems incredibly simple to me! (now !)

My brain is aging !

Thank you.

ciao