public static void SetLightweightToResolved(this Component2 component)
        {
            var suppressionState = (swComponentSuppressionState_e)component.GetSuppression();

            switch (suppressionState)
            {
            case swComponentSuppressionState_e.swComponentFullyResolved:
            case swComponentSuppressionState_e.swComponentResolved:
                return;

            case swComponentSuppressionState_e.swComponentFullyLightweight:
            case swComponentSuppressionState_e.swComponentLightweight:
                var error = (swSuppressionError_e)component.SetSuppression2((int)swComponentSuppressionState_e.swComponentResolved);
                break;
            }
        }
示例#2
0
 private void ShowConfigurationDetails(Component2 component, ModelDoc2 model, string nameConfiguration)
 {
     if (SwAddin.needWait)
     {
         ProgressBar.WaitTime.Instance.ShowWait();
         ProgressBar.WaitTime.Instance.SetLabel("Ожидание завершения предедущих операций.");
         lock (SwAddin.workerLocker)
             Monitor.Wait(SwAddin.workerLocker);
         ProgressBar.WaitTime.Instance.HideWait();
     }
     if (component.Select(false) && ((AssemblyDoc)model).CompConfigProperties4(component.GetSuppression(), 0, true, true, nameConfiguration, false))
     {
         int err = 0, wrn = 0;
         var mod = _mSwAddin.SwApp.OpenDoc6(component.IGetModelDoc().GetPathName(),
                                            component.IGetModelDoc().GetType(), 0, nameConfiguration, ref err, ref wrn);
         var dict = new Dictionary<Component2, ModelDoc2>();
         if (mod != null)
         {
             mod.ShowConfiguration2(nameConfiguration);
             if (mod.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY)
             {
                 var outList = new LinkedList<Component2>();
                 if (_mSwAddin.GetComponents(mod.IGetActiveConfiguration().IGetRootComponent2(), outList, true,
                                             false))
                 {
                     foreach (var component2 in outList)
                     {
                         if (mod.GetEquationMgr().GetCount() > 0)
                             for (int i = 0; i < mod.GetEquationMgr().GetCount(); i++)
                             {
                                 if (mod.GetEquationMgr().get_Equation(i).Contains(
                                     Path.GetFileNameWithoutExtension(component2.GetPathName())))
                                 {
                                     if (mod.GetEquationMgr().get_Suppression(i) != component2.IsSuppressed())
                                         mod.GetEquationMgr().set_Suppression(i, component2.IsSuppressed());
                                 }
                             }
                     }
                     foreach (var component2 in outList)
                     {
                         var m = component2.IGetModelDoc();
                         if (m != null && m.GetConfigurationCount() > 1)
                         {
                             if (dict.ContainsKey(component2))
                                 dict.Add(component2, component.IGetModelDoc());
                         }
                     }
                 }
             }
             mod.Save();
             _mSwAddin.SwApp.CloseDoc(mod.GetPathName());
         }
         foreach (var d in dict)
             ShowConfigurationDetails(d.Key, d.Value, d.Key.ReferencedConfiguration);
     }
 }
示例#3
0
        private bool GetComponentModel(ModelDoc2 swModel, Component2 inComp, out ModelDoc2 swCompModel, out string modelFileName)
        {
            int i = 0;
            modelFileName = "";
            do
            {
                var compState = (swComponentSuppressionState_e)inComp.GetSuppression();

                if (compState.ToString() == "swComponentSuppressed")
                    inComp.SetSuppression2((int)swComponentSuppressionState_e.swComponentFullyResolved);

                swCompModel = (ModelDoc2)inComp.GetModelDoc();

                if (swCompModel == null)
                {
                    string newModelPath = CheckIsCompInOurLib(inComp.GetPathName());
                    if (inComp.Select(false))
                    {
                        ((AssemblyDoc)swModel).ReplaceComponents(newModelPath, "", true, true);
                        //((AssemblyDoc) swModel).ComponentReload();
                        swCompModel = inComp.IGetModelDoc();
                        //((AssemblyDoc) swModel).OpenCompFile();
                        //��� �������������� ��������� ���������� OpenCompFile �� ��������!
                        if (((ModelDoc2)_iSwApp.ActiveDoc).GetPathName() != swModel.GetPathName())
                            swCompModel = (ModelDoc2)_iSwApp.ActiveDoc;
                    }
                }
                i++;
            } while (swCompModel == null && i < 10);

            if (swCompModel != null)
                modelFileName = swCompModel.GetPathName();
            else
            {
                MessageBox.Show(@"��������� " + inComp.Name + @"�� ���������!", MyTitle, MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return false;
            }
            return true;
        }