public void AttachEventsToAllDocuments() { ModelDoc2 modDoc = (ModelDoc2)SwApp.GetFirstDocument(); while (modDoc != null) { if (!OpenDocs.Contains(modDoc)) { AttachModelDocEventHandler(modDoc); } else if (OpenDocs.Contains(modDoc)) { DocumentEventHandler docHandler = (DocumentEventHandler)OpenDocs[modDoc]; if (docHandler != null) { bool connected = docHandler.ConnectModelViews(); if (!connected) { logger.Warn("Failed to connect to model views"); } } } modDoc = (ModelDoc2)modDoc.GetNext(); } }