private void ConnectDocumentEvents(SolidEdgeFramework.SolidEdgeDocument document) { _documentEvents = (SolidEdgeFramework.ISEDocumentEvents_Event)document.DocumentEvents; switch (document.Type) { case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument: var assemblyDocument = (SolidEdgeAssembly.AssemblyDocument)document; _assemblyChangeEvents = (SolidEdgeFramework.ISEAssemblyChangeEvents_Event)assemblyDocument.AssemblyChangeEvents; _assemblyFamilyEvents = (SolidEdgeFramework.ISEAssemblyFamilyEvents_Event)assemblyDocument.AssemblyFamilyEvents; _assemblyRecomputeEvents = (SolidEdgeFramework.ISEAssemblyRecomputeEvents_Event)assemblyDocument.AssemblyRecomputeEvents; break; case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument: var draftDocument = (SolidEdgeDraft.DraftDocument)document; _blockTableEvents = (SolidEdgeFramework.ISEBlockTableEvents_Event)draftDocument.BlockTableEvents; _connectorTableEvents = (SolidEdgeFramework.ISEConnectorTableEvents_Event)draftDocument.ConnectorTableEvents; _draftBendTableEvents = (SolidEdgeFramework.ISEDraftBendTableEvents_Event)draftDocument.DraftBendTableEvents; _drawingViewEvents = (SolidEdgeFramework.ISEDrawingViewEvents_Event)draftDocument.DrawingViewEvents; _partsListEvents = (SolidEdgeFramework.ISEPartsListEvents_Event)draftDocument.PartsListEvents; break; case SolidEdgeFramework.DocumentTypeConstants.igPartDocument: var partDocument = (SolidEdgePart.PartDocument)document; _dividePartEvents = (SolidEdgeFramework.ISEDividePartEvents_Event)partDocument.DividePartEvents; _familyOfPartsEvents = (SolidEdgeFramework.ISEFamilyOfPartsEvents_Event)partDocument.FamilyOfPartsEvents; _familyOfPartsExEvents = (SolidEdgeFramework.ISEFamilyOfPartsExEvents_Event)partDocument.FamilyOfPartsExEvents; break; case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument: var sheetMetalDocument = (SolidEdgePart.SheetMetalDocument)document; _dividePartEvents = (SolidEdgeFramework.ISEDividePartEvents_Event)sheetMetalDocument.DividePartEvents; _familyOfPartsEvents = (SolidEdgeFramework.ISEFamilyOfPartsEvents_Event)sheetMetalDocument.FamilyOfPartsEvents; _familyOfPartsExEvents = (SolidEdgeFramework.ISEFamilyOfPartsExEvents_Event)sheetMetalDocument.FamilyOfPartsExEvents; break; } if (_documentEvents != null) { _documentEvents.AfterSave += ISEDocumentEvents_AfterSave; _documentEvents.BeforeClose += ISEDocumentEvents_BeforeClose; _documentEvents.BeforeSave += ISEDocumentEvents_BeforeSave; _documentEvents.SelectSetChanged += ISEDocumentEvents_SelectSetChanged; } if (_assemblyChangeEvents != null) { _assemblyChangeEvents.AfterChange += ISEAssemblyChangeEvents_AfterChange; _assemblyChangeEvents.BeforeChange += ISEAssemblyChangeEvents_BeforeChange; } if (_assemblyFamilyEvents != null) { _assemblyFamilyEvents.AfterMemberActivate += ISEAssemblyFamilyEvents_AfterMemberActivate; _assemblyFamilyEvents.AfterMemberCreate += ISEAssemblyFamilyEvents_AfterMemberCreate; _assemblyFamilyEvents.AfterMemberDelete += ISEAssemblyFamilyEvents_AfterMemberDelete; _assemblyFamilyEvents.BeforeMemberActivate += ISEAssemblyFamilyEvents_BeforeMemberActivate; _assemblyFamilyEvents.BeforeMemberCreate += ISEAssemblyFamilyEvents_BeforeMemberCreate; _assemblyFamilyEvents.BeforeMemberDelete += ISEAssemblyFamilyEvents_BeforeMemberDelete; } if (_assemblyRecomputeEvents != null) { _assemblyRecomputeEvents.AfterAdd += ISEAssemblyRecomputeEvents_AfterAdd; _assemblyRecomputeEvents.AfterModify += ISEAssemblyRecomputeEvents_AfterModify; _assemblyRecomputeEvents.AfterRecompute += ISEAssemblyRecomputeEvents_AfterRecompute; _assemblyRecomputeEvents.BeforeDelete += ISEAssemblyRecomputeEvents_BeforeDelete; _assemblyRecomputeEvents.BeforeRecompute += ISEAssemblyRecomputeEvents_BeforeRecompute; } if (_blockTableEvents != null) { _blockTableEvents.AfterUpdate += ISEBlockTableEvents_AfterUpdate; } if (_connectorTableEvents != null) { _connectorTableEvents.AfterUpdate += ISEConnectorTableEvents_AfterUpdate; } if (_draftBendTableEvents != null) { _draftBendTableEvents.AfterUpdate += ISEDraftBendTableEvents_AfterUpdate; } if (_drawingViewEvents != null) { _drawingViewEvents.AfterUpdate += ISEDrawingViewEvents_AfterUpdate; } if (_partsListEvents != null) { _partsListEvents.AfterUpdate += ISEPartsListEvents_AfterUpdate; } if (_dividePartEvents != null) { _dividePartEvents.AfterDividePartDocumentCreated += ISEDividePartEvents_AfterDividePartDocumentCreated; _dividePartEvents.AfterDividePartDocumentRenamed += ISEDividePartEvents_AfterDividePartDocumentRenamed; _dividePartEvents.BeforeDividePartDocumentDeleted += ISEDividePartEvents_BeforeDividePartDocumentDeleted; } if (_familyOfPartsEvents != null) { _familyOfPartsEvents.AfterMemberDocumentCreated += ISEFamilyOfPartsEvents_AfterMemberDocumentCreated; _familyOfPartsEvents.AfterMemberDocumentRenamed += ISEFamilyOfPartsEvents_AfterMemberDocumentRenamed; _familyOfPartsEvents.BeforeMemberDocumentDeleted += ISEFamilyOfPartsEvents_BeforeMemberDocumentDeleted; } if (_familyOfPartsExEvents != null) { _familyOfPartsExEvents.AfterMemberDocumentCreated += ISEFamilyOfPartsExEvents_AfterMemberDocumentCreated; _familyOfPartsExEvents.AfterMemberDocumentRenamed += ISEFamilyOfPartsExEvents_AfterMemberDocumentRenamed; _familyOfPartsExEvents.BeforeMemberDocumentDeleted += ISEFamilyOfPartsExEvents_BeforeMemberDocumentDeleted; } }