public void AttachEventsToAllDocuments() { ModelDoc2 modDoc = (ModelDoc2)iSwApp.GetFirstDocument(); while (modDoc != null) { if (!openDocs.Contains(modDoc)) { AttachModelDocEventHandler(modDoc); } else if (openDocs.Contains(modDoc)) { bool connected = false; DocumentEventHandler docHandler = (DocumentEventHandler)openDocs[modDoc]; if (docHandler != null) { connected = docHandler.ConnectModelViews(); } } modDoc = (ModelDoc2)modDoc.GetNext(); } }