public static List <ModelDoc2> ListCurrentlyOpened() { List <ModelDoc2> openedDocs = new List <ModelDoc2>(); ModelDoc2 swModel = Instance.GetFirstDocument(); while (swModel != null) { /* Assembly components are opened, but are not visible * until opened by the user */ // Debug.WriteLine(swModel.GetTitle() + " [" + swModel.GetType() + "]"); /* The document name contains a filename extension * if the document has been saved * and is subject to Microsoft Windows Explorer setting; * the document name does not contain a * filename extension if the document has not been saved; * ModelDoc2::GetPathName is blank until the file is saved */ openedDocs.Add(swModel); swModel = swModel.GetNext(); } return(openedDocs); }
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(); } }
public List <string> get_list_of_open_docs() { ModelDoc2 temp = (ModelDoc2)swApp.GetFirstDocument(); List <string> ml = new List <string>(); temp.GetNext(); while (temp != null) { string temp_string = temp.GetPathName(); if (temp.Visible == true && !ml.Contains(temp_string)) { ml.Add(temp.GetPathName()); } temp = (ModelDoc2)temp.GetNext(); } return(ml); }
public void AttachEventsToAllDocuments() { ModelDoc2 modDoc = (ModelDoc2)iSwApp.GetFirstDocument(); while (modDoc != null) { if (!openDocs.Contains(modDoc)) { AttachModelDocEventHandler(modDoc); } modDoc = (ModelDoc2)modDoc.GetNext(); } }
public int OnDocLoad(string docTitle, string docPath) { ModelDoc2 modDoc = (ModelDoc2)iSwApp.GetFirstDocument(); while (modDoc != null) { if (modDoc.GetTitle() == docTitle) { if (!openDocs.Contains(modDoc)) { AttachModelDocEventHandler(modDoc); } } modDoc = (ModelDoc2)modDoc.GetNext(); } return(0); }
/// <summary> /// Get the first open document from the addin, iterates through the documents and then /// if they don't have event handlers, attaches it to them based on the document type /// </summary> public void AttachEventsToAllDocuments() { ModelDoc2 ThisDocument = (ModelDoc2)solidworks.GetFirstDocument(); while (ThisDocument != null) { if (!documentsEventsRepo.Contains(ThisDocument)) { AttachEventHandlersToDocument(ThisDocument); } else if (documentsEventsRepo.Contains(ThisDocument)) { DocumentEventHandler documentEventHandler = (DocumentEventHandler)documentsEventsRepo[ThisDocument]; if (documentEventHandler != null) { documentEventHandler.ConnectModelViews(); } } ThisDocument = (ModelDoc2)ThisDocument.GetNext(); } }
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(); } }
public void ChangeActiveDoc(bool isDestroy) { RemoveSetParametersForm(); string tmp = _iSwApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swFileLocationsDesignLibrary); if ((tmp.ToLower().Contains("_swlib_backup") && !Properties.Settings.Default.CashModeOn) || (!tmp.ToLower().Contains("_swlib_backup") && Properties.Settings.Default.CashModeOn)) ChangeCashMode(); SwModel = (ModelDoc2)_iSwApp.ActiveDoc; bool isProceedMenuChanging = true; if (isDestroy) { while (SwModel != null) { SwModel = (ModelDoc2)SwModel.GetNext(); if (SwModel != null) if (SwModel.Visible) { isProceedMenuChanging = false; break; } } } if (isProceedMenuChanging) { var docType = (int)swDocumentTypes_e.swDocNONE; if (SwModel != null) docType = SwModel.GetType(); //��������� ���� ��������� RemoveMenu(); _iSwApp.AddMenu(docType, MyTitle, docType == (int)swDocumentTypes_e.swDocNONE ? 3 : 5); if (docType == (int)swDocumentTypes_e.swDocASSEMBLY) { _iSwApp.AddMenuItem2(docType, _addinId, "MrDoors ���@" + MyTitle, -1, "ShowSetParameters", "ShowSetParametersEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������ ���� �������@" + MyTitle, -1, "GetProjectPrice", "GetProjectPriceEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� � �������@" + MyTitle, -1, "PurchaseExport", "PurchaseExportEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); _iSwApp.AddMenuItem2(docType, _addinId, "����������� ��������� ����������@" + MyTitle, -1, "SaveAsComponents", "SaveAsComponentsEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "����������� ������ � ������ �����@" + MyTitle, -1, "CopyProjectFormShow", "CopyProjectFormShowEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "�������� ���@" + MyTitle, -1, "CopyToLocal", "CopyToLocalEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "����������� ������������ �������@" + MyTitle, -1, "RecalculateRanges", "RecalculateRangesEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "����������� ��������� ��� ������(�� �������)@" + MyTitle, -1, "CutOffDetail", "SaveAsComponentsEnable", ""); if (Properties.Settings.Default.KitchenModeOn) _iSwApp.AddMenuItem2(docType, _addinId, "����������� ����� �����. ������ ����� �����: ���@" + MyTitle, -1, "ChangeKitchenMode", "ChangeKitchenModeEnable", ""); else _iSwApp.AddMenuItem2(docType, _addinId, "����������� ����� �����. ������ ����� �����: ����@" + MyTitle, -1, "ChangeKitchenMode", "ChangeKitchenModeEnable", ""); if (Properties.Settings.Default.CashModeOn) _iSwApp.AddMenuItem2(docType, _addinId, "����������� ����� ����. ������ ����� ����: ���@" + MyTitle, -1, "ChangeCashMode", "ChangeCashModeEnable", ""); else _iSwApp.AddMenuItem2(docType, _addinId, "����������� ����� ����. ������ ����� ����: ����@" + MyTitle, -1, "ChangeCashMode", "ChangeCashModeEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� �����@" + MyTitle, -1, "CreateMetering", "CreateMeteringEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ��������� � ������@" + MyTitle, -1, "CutOff", "CutOffEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "��������� �� ����������� ���������@" + MyTitle, -1, "CheckCutOff", "CheckCutOffEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ��� ��������� ���������@" + MyTitle, -1, "RemoveCavity", "RemoveCavityEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ��������� ���������@" + MyTitle, -1, "RemoveErrorCavity", "RemoveErrorCavityEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ����� ����� ��������� ������������@" + MyTitle, -1, "FixColor", "FixColorEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "�������� ��������� ����������@" + MyTitle, -1, "ReplaceComponents", "ReplaceComponentsEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); _iSwApp.AddMenuItem2(docType, _addinId, "���������� �������@" + MyTitle, -1, "CopyDrawings", "CopyDrawingsEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ��� �������@" + MyTitle, -1, "OpenDrawings", "OpenDrawingsEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������������� ��������� ������@" + MyTitle, -1, "StartFinalProcessing", "FinalProcessingEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); _iSwApp.AddMenuItem2(docType, _addinId, "����������� ��� �������@" + MyTitle, -1, "DimensionAll", "DimensionAllEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); } if (docType == (int)swDocumentTypes_e.swDocDRAWING) { //_iSwApp.AddMenuItem2(docType, _addinId, "������������������� �������@" + MyTitle, -1, "AutoScaleDrawing", "AutoScaleDrawingEnable", ""); //_iSwApp.AddMenuItem2(docType, _addinId, "Xml@" + MyTitle, -1, "Xml", "XmlEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� �������� ����������� ���������@" + MyTitle, -1, "AddHolesSymbols", "AddHolesSymbolsEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); _iSwApp.AddMenuItem2(docType, _addinId, "�������������� �������@" + MyTitle, -1, "AutoDimensionDrawing", "AutoDimensionDrawingEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ������� � �����@" + MyTitle, -1, "DeleteSketchDemensions", "DeleteSketchDemensionsEnable", ""); } if (docType == (int)swDocumentTypes_e.swDocNONE) { _iSwApp.AddMenuItem2(docType, _addinId, "������������������@" + MyTitle, -1, "AutoRecovery", "AutoRecoveryEnable", ""); _iSwApp.AddMenuItem2(docType, _addinId, "������� ���. ������ ��������.@" + MyTitle, -1, "CreateCash", "CreateCashEnable", ""); //_iSwApp.AddMenuItem2(docType, _addinId, "�������� ��� �������� �������� ����.@" + MyTitle, -1,"CheckAccessories", "CheckAccessoriesEnable", ""); } if (docType == (int)swDocumentTypes_e.swDocPART && Properties.Settings.Default.KitchenModeOn) { _iSwApp.AddMenuItem2(docType, _addinId, "������������� ���������@" + MyTitle, -1, "GeneratePlane", "GeneratePlaneEnable", ""); } _iSwApp.AddMenuItem2(docType, _addinId, "���������@" + MyTitle, -1, "ShowOptions", "", ""); //if (Properties.Settings.Default.CheckUpdateLib) //{ // _iSwApp.AddMenuItem2(docType, _addinId, "@" + MyTitle, -1, "ShowOptions", "", ""); // _iSwApp.AddMenuItem2(docType, _addinId, "���������� ����������@" + MyTitle, -1, "UpdateLib", // "", ""); //} } }