.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I count the number of deactivated documents ?

6 REPLIES 6
Reply
Message 1 of 7
joantopo
434 Views, 6 Replies

How can I count the number of deactivated documents ?

Hi.

I´m using the events "DocumentActivated" and  the event "DocumentDestroyed" .

With the "DocumentDestroyed" method I can know how many documents are closed and when is the last..

 

But, I want to know, how many documents are minimized (deactivated).

It´s to say, there aren´t any active (current) document.

 

Trank you.

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
6 REPLIES 6
Message 2 of 7

The DocumentCollection's Count property tells you how many documents exist.

 

There can be only one active document so the number of 'deactivated' documents is the value of the Count property minus 1.  

 

When the DocumentToBeDestroyed event fires, if the document that's about to be destroyed is the only open document, then at that point, the DocumentCollection's Count property will be 1, and it means that AutoCAD is entering 'zero document state' (where there are no open documents).

 

 

Message 3 of 7

ok, but if I have all my documents as a(deactivated) documents. Which is the active document?  What´s the name or Id of this?

Because I can have all my documents as a deactivated document.

 

Thank you for reply.

 

 

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 4 of 7
jeff
in reply to: joantopo


@joantopo wrote:

Because I can have all my documents as a deactivated document.


 How do you do that?


@joantopo wrote:

but if I have all my documents as a(deactivated) documents. Which is the active document?   


If you have them all "deactivated" then how could one active?

 

I just noticed you mention minimized so when you say "deactivated" you mean minimized?

You can still enter commands and interact with active document when all them all minimized, but I think your looking for

Application.DocumentManager.MdiActiveDocument.Window.WindowState

 

You can also find your answers @ TheSwamp
Message 5 of 7
joantopo
in reply to: jeff

Yes, all right.

 

I was confusing deactivated with minimized.  I wanted to say "minimized".

 

I´m going to try this line code.

 

Thank you.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 6 of 7
joantopo
in reply to: joantopo

I don´t understand because Autodesk interpret that the window state = normal is the same that state=minimized..Smiley Frustrated

                 private void callback_documentActivated(object sender, DocumentCollectionEventArgs e)
                {

                  if (ComprobarTodosMinimizados()==false)
                     
                     System.Windows.Forms.MessageBox.Show("abiertoooooooo");
                  else

                      System.Windows.Forms.MessageBox.Show("todos minimizados");
                 }

                 public bool ComprobarTodosMinimizados()
                 {

                     bool TodosMinimizados = false;
                     int contador = 0;
                     DocumentCollection docs = Application.DocumentManager;

                     foreach (Document doc in docs)
                     {
                          
                        if (doc.Window.WindowState == Autodesk.AutoCAD.Windows.Window.State.Minimized);  // si se minimiza la ventana
                        {
                            contador++;
                        }
                     }
                     if (contador == Application.DocumentManager.Count)
                     {
                         TodosMinimizados = true;
                     }

                 
                 return TodosMinimizados;
                 
                 }

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 7 of 7
joantopo
in reply to: joantopo

is this right?

 if (doc.Window.WindowState == Autodesk.AutoCAD.Windows.Window.State.Minimized); 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost