Exemplo n.º 1
0
        /// <summary>
        /// Convert  ModelDoc2 to AssemblyDoc and resolve all light weight components
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static AssemblyDoc  ToAssemblyDocument(ModelDoc2 document)
        {
            AssemblyDoc swAsm = (AssemblyDoc)document;

            swAsm.ResolveAllLightWeightComponents(false);
            return(swAsm);
        }
Exemplo n.º 2
0
        public List <Item> GetItems()
        {
            var list = new List <Item>();

            assembly.ResolveAllLightWeightComponents(false);

            var assemblyComponents = ((Array)assembly.GetComponents(TopLevelOnly))
                                     .Cast <Component2>()
                                     .Where(c => !c.IsHidden(true));

            var componentGroups = assemblyComponents
                                  .GroupBy(c => c.GetTitle() + c.ReferencedConfiguration);

            foreach (var group in componentGroups)
            {
                var component = group.First();
                var model     = component.GetModelDoc2() as ModelDoc2;

                if (model == null)
                {
                    continue;
                }

                var name = GetComponentName(component);

                list.Add(new Item
                {
                    PartName  = name,
                    Quantity  = group.Count(),
                    Component = component
                });
            }

            return(list);
        }
        /// <summary>
        /// Convert  ModelDoc2 to AssemblyDoc and resolve all light weight components
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static AssemblyDoc ToAssemblyDocument(ModelDoc2 document)
        {
            AssemblyDoc swAsm = null;

            try
            {
                if ((int)swDocumentTypes_e.swDocASSEMBLY == document.GetType())
                {
                    swAsm = (AssemblyDoc)document;
                    swAsm.ResolveAllLightWeightComponents(false);
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                throw;
            }
            return(swAsm);
        }
Exemplo n.º 4
0
        // Called when a PropertyManagerPageButton is pressed. In our case, that's only the export button for now
        void IPropertyManagerPage2Handler9.OnButtonPress(int Id)
        {
            if (Id == Button_export_ID) //If the export button was pressed
            {
                saveActiveNode();
                if (checkIfNamesAreUnique((LinkNode)tree.Nodes[0]) && checkNodesComplete(tree)) // Only if everything is A-OK, then do we proceed.
                {
                    pm_Page.Close(true);                                                        //It saves automatically when sending Okay as true;
                    AssemblyDoc assy = (AssemblyDoc)ActiveSWModel;

                    //This call can be a real sink of processing time if the model is large. Unfortunately there isn't a way around it I believe.
                    int result = assy.ResolveAllLightWeightComponents(true);

                    // If the user confirms to resolve the components and they are successfully resolved we can continue
                    if (result == (int)swComponentResolveStatus_e.swResolveOk)
                    {
                        // Builds the links and joints from the PMPage configuration
                        LinkNode BaseNode = (LinkNode)tree.Nodes[0];
                        automaticallySwitched = true;
                        tree.Nodes.Remove(BaseNode);

                        Exporter.createRobotFromTreeView(BaseNode);
                        AssemblyExportForm exportForm = new AssemblyExportForm(swApp, BaseNode);
                        exportForm.Exporter = Exporter;
                        exportForm.Show();
                    }
                    else if (result == (int)swComponentResolveStatus_e.swResolveError || result == (int)swComponentResolveStatus_e.swResolveNotPerformed)
                    {
                        MessageBox.Show("Resolving components failed. In order to export to URDF, this tool needs all components to be resolved. Try resolving lightweight components manually before attempting to export again");
                    }
                    else if (result == (int)swComponentResolveStatus_e.swResolveAbortedByUser)
                    {
                        MessageBox.Show("In order to export to URDF, this tool needs all components to be resolved. You can resolve them manually or try exporting again");
                    }
                }
            }
        }
Exemplo n.º 5
0
        public string Build(SpigotType_e type, int width, int height)
        {
            string modelName = GetModelName(type);

            NewSpigotName = GetSpigotName(type, width, height);


            Dimension dimension;

            int addDimH = modelName == "12-30" ? 10 : 1;

            string newSpigotPath = $@"{RootFolder}{SubjectDestinationFolder}\{NewSpigotName}";

            string drawingName = modelName == "12-30" ? modelName : "12-00";

            var modelSpigotDrw = $@"{RootFolder}{SourceFolder}\{drawingName}.SLDDRW";

            ModelDoc2 swDrawingSpigot = SolidWorksAdapter.OpenDocument(modelSpigotDrw, swDocumentTypes_e.swDocDRAWING);

            solidWorksDocument = SolidWorksAdapter.AcativeteDoc("12-00");
            AssemblyDoc assemblyDocument = (AssemblyDoc)solidWorksDocument;

            assemblyDocument.ResolveAllLightWeightComponents(false);

            DeleteEquations(modelName);
            solidWorksDocument.ForceRebuild3(true);

            #region formuls
            var          w          = (Convert.ToDouble(width) - 1) / 1000;                                   // ????????????
            var          h          = Convert.ToDouble((Convert.ToDouble(height) + addDimH) / 1000);          // ????????????
            const double step       = 50;
            var          weldWidth  = Convert.ToDouble((Math.Truncate(Convert.ToDouble(width) / step) + 1));  // ????????????
            var          weldHeight = Convert.ToDouble((Math.Truncate(Convert.ToDouble(height) / step) + 1)); // ????????????
            #endregion

            DeleteComponents((int)type);
            if (modelName == "12-20")
            {
                PartName = $"12-20-{height}.SLDPRT";
                if (CheckExistPart != null)
                {
                    CheckExistPart(PartName, out IsPartExist, out NewPartPath);
                }
                else
                {
                    MessageObserver.Instance.SetMessage("CheckExistPartEvent can not be null", MessageType.Warning);
                }

                if (IsPartExist)
                {
                    solidWorksDocument.Extension.SelectByID2("12-20-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    assemblyDocument.ReplaceComponents(NewPartPath, "", true, true);
                }
                else
                {
                    NewPartPath = $@"{RootFolder}\{SubjectDestinationFolder}\{NewPartPath}";
                    solidWorksDocument.Extension.SelectByID2("D1@Вытянуть1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Вытянуть[email protected]")));
                    dimension.SystemValue = h - 0.031;
                    solidWorksDocument.Extension.SelectByID2("D1@Кривая1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Кривая[email protected]")));
                    dimension.SystemValue = weldHeight;
                    SolidWorksDocument.Extension.SaveAs(NewPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
                    InitiatorSaveExeption(error, warning, NewPartPath);
                    ComponentsPathList.Add(NewPartPath);
                    SolidWorksAdapter.SldWoksAppExemplare.CloseDoc(NewPartPath);
                }

                //12-20-002

                PartName = $"12-20-{width}.SLDPRT";

                MessageObserver.Instance.SetMessage("Check exist part. " + NewPartPath);
                if (CheckExistPart != null)
                {
                    MessageObserver.Instance.SetMessage("\tCheckExistPartEvent");
                    CheckExistPart(PartName, out IsPartExist, out NewPartPath);
                }
                else
                {
                    MessageObserver.Instance.SetMessage("CheckExistPartEvent can not be null", MessageType.Warning);
                }

                if (IsPartExist)
                {
                    solidWorksDocument.Extension.SelectByID2("12-20-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    assemblyDocument.ReplaceComponents(PartName, "", true, true);
                }
                else
                {
                    NewPartPath = $@"{RootFolder}\{SubjectDestinationFolder}\{NewPartPath}";
                    solidWorksDocument.Extension.SelectByID2("D1@Вытянуть1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Вытянуть[email protected]")));
                    dimension.SystemValue = w - 0.031;
                    solidWorksDocument.Extension.SelectByID2("D1@Кривая1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Кривая[email protected]")));
                    dimension.SystemValue = weldWidth;
                    SolidWorksDocument.Extension.SaveAs(NewPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
                    InitiatorSaveExeption(error, warning, NewPartPath);
                    ComponentsPathList.Add(NewPartPath);
                }

                //12-003
                PartName = $"12-03-{width}-{height}.SLDPRT";
                if (CheckExistPart != null)
                {
                    CheckExistPart(PartName, out IsPartExist, out NewPartPath);
                }
                else
                {
                    MessageObserver.Instance.SetMessage("CheckExistPartEvent can not be null", MessageType.Warning);
                }
                if (IsPartExist)
                {
                    solidWorksDocument.Extension.SelectByID2("12-003-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    assemblyDocument.ReplaceComponents(PartName, "", true, true);
                }
                else
                {
                    NewPartPath = $@"{RootFolder}\{SubjectDestinationFolder}\{NewPartPath}";
                    solidWorksDocument.Extension.SelectByID2("D3@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D3@Эскиз[email protected]")));
                    dimension.SystemValue = w;
                    solidWorksDocument.Extension.SelectByID2("D2@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D2@Эскиз[email protected]")));
                    dimension.SystemValue = h;
                    solidWorksDocument.EditRebuild3();
                    SolidWorksDocument.Extension.SaveAs(NewPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
                    InitiatorSaveExeption(error, warning, NewPartPath);
                    ComponentsPathList.Add(NewPartPath);
                    SolidWorksAdapter.SldWoksAppExemplare.CloseDoc(NewPartPath);
                }
            }
            if (modelName == "12-30")
            {
                //12-30-001

                PartName = $"12-30-{height}.SLDPRT";

                MessageObserver.Instance.SetMessage("Check exist part. " + NewPartPath);
                if (CheckExistPart != null)
                {
                    CheckExistPart(PartName, out IsPartExist, out NewPartPath);
                }
                else
                {
                    MessageObserver.Instance.SetMessage("CheckExistPartEvent can not be null", MessageType.Warning);
                }

                if (IsPartExist)
                {
                    solidWorksDocument.Extension.SelectByID2("12-30-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    assemblyDocument.ReplaceComponents(PartName, "", true, true);
                }
                else
                {
                    NewPartPath = $@"{RootFolder}\{SubjectDestinationFolder}\{NewPartPath}";
                    solidWorksDocument.Extension.SelectByID2("D1@Вытянуть1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Вытянуть[email protected]")));
                    dimension.SystemValue = h - 0.031;
                    solidWorksDocument.Extension.SelectByID2("D1@Кривая1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Кривая[email protected]")));
                    dimension.SystemValue = weldHeight;
                    SolidWorksDocument.Extension.SaveAs(NewPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
                    InitiatorSaveExeption(error, warning, NewPartPath);
                    ComponentsPathList.Add(NewPartPath);
                }
                //12-30-002
                PartName = $"12-30-{width}.SLDPRT";


                if (CheckExistPart != null)
                {
                    CheckExistPart(PartName, out IsPartExist, out NewPartPath);
                }
                else
                {
                    MessageObserver.Instance.SetMessage("CheckExistPartEvent can not be null", MessageType.Warning);
                }

                if (IsPartExist)
                {
                    solidWorksDocument.Extension.SelectByID2("12-30-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    assemblyDocument.ReplaceComponents(PartName, "", true, true);
                }
                else
                {
                    NewPartPath = $@"{RootFolder}\{SubjectDestinationFolder}\{NewPartPath}";
                    solidWorksDocument.Extension.SelectByID2("D1@Вытянуть1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Вытянуть[email protected]")));
                    dimension.SystemValue = w - 0.031;
                    solidWorksDocument.Extension.SelectByID2("D1@Кривая1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D1@Кривая[email protected]")));
                    dimension.SystemValue = weldHeight;
                    SolidWorksDocument.Extension.SaveAs(NewPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
                    InitiatorSaveExeption(error, warning, NewPartPath);
                    ComponentsPathList.Add(NewPartPath);
                }
                //12-003

                PartName = $"12-03-{width}-{height}.SLDPRT";
                if (CheckExistPart != null)
                {
                    CheckExistPart(PartName, out IsPartExist, out NewPartPath);
                }
                else
                {
                    MessageObserver.Instance.SetMessage("CheckExistPartEvent can not be null", MessageType.Warning);
                }

                if (IsPartExist)
                {
                    solidWorksDocument.Extension.SelectByID2("12-003-2@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    assemblyDocument.ReplaceComponents(PartName, "", true, true);
                }
                else
                {
                    NewPartPath = $@"{RootFolder}\{SubjectDestinationFolder}\{NewPartPath}";
                    solidWorksDocument.Extension.SelectByID2("D3@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D3@Эскиз[email protected]")));
                    dimension.SystemValue = w;
                    solidWorksDocument.Extension.SelectByID2("D2@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0);
                    dimension             = ((Dimension)(solidWorksDocument.Parameter("D2@Эскиз[email protected]")));
                    dimension.SystemValue = h;
                    solidWorksDocument.EditRebuild3();
                    SolidWorksDocument.Extension.SaveAs(NewPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
                    InitiatorSaveExeption(error, warning, NewPartPath);
                    ComponentsPathList.Add(NewPartPath);
                }
            }

            solidWorksDocument.ForceRebuild3(true);
            solidWorksDocument.Extension.SaveAs(newSpigotPath + ".SLDASM", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
            InitiatorSaveExeption(error, warning, newSpigotPath + ".SLDASM");

            SolidWorksAdapter.SldWoksAppExemplare.CloseDoc(NewSpigotName + ".SLDASM");
            ComponentsPathList.Add(newSpigotPath + ".SLDASM");
            swDrawingSpigot.Extension.SelectByID2("DRW1", "SHEET", 0, 0, 0, false, 0, null, 0);
            var drw = (DrawingDoc)SolidWorksAdapter.AcativeteDoc(drawingName + ".SLDDRW");
            drw.ActivateSheet("DRW1");
            drw.SetupSheet5("DRW1", 12, 12, 1, GetDrawingScale(width, height), true, @"\\pdmsrv\SolidWorks Admin\Templates\Основные надписи\A3-A-1.slddrt", 0.42, 0.297, "По умолчанию", false);
            swDrawingSpigot.Extension.SaveAs(newSpigotPath + ".SLDDRW", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warning);
            InitiatorSaveExeption(error, warning, newSpigotPath + ".SLDDRW");

            ComponentsPathList.Add(newSpigotPath + ".SLDDRW");
            SolidWorksAdapter.CloseAllDocumentsAndExit();
            return(newSpigotPath);
        }
Exemplo n.º 6
0
        public static List <Comp> GetColl(AssemblyDoc swAssy, SldWorks swApp)
        {
            Comp        component;
            List <Comp> coll;

            object[]              comps;
            Component2            comp;
            ModelDoc2             compDoc, swModel;
            CustomPropertyManager prpMgr;
            ModelDocExtension     swModelDocExt;
            swDocumentTypes_e     docType = swDocumentTypes_e.swDocPART;
            ConfigurationManager  confManager;
            string configuration;

            double[] aTrans;
            string   path;

            coll = new List <Comp>();

            swAssy.ResolveAllLightWeightComponents(false);

            comps = (object[])swAssy.GetComponents(true);

            for (int i = 0; i < comps.Length; i++)
            {
                component     = new Comp();
                swModel       = (ModelDoc2)swAssy;
                swModelDocExt = swModel.Extension;


                confManager   = (ConfigurationManager)swModel.ConfigurationManager;
                configuration = confManager.ActiveConfiguration.Name;
                prpMgr        = swModelDocExt.get_CustomPropertyManager(configuration);
                prpMgr.Get4("Обозначение", true, out string valOut, out _);
                component.used = valOut;

                comp = (Component2)comps[i];
                path = comp.GetPathName();
                if ((comp.GetSuppression() != (int)swComponentSuppressionState_e.swComponentSuppressed) & (comps[i] != null))
                {
                    aTrans = (double[])comp.Transform2.ArrayData;
                    if (path.ToUpper().EndsWith(".SLDASM"))
                    {
                        docType = (swDocumentTypes_e)swDocumentTypes_e.swDocASSEMBLY;
                    }
                    if (path.ToUpper().EndsWith(".SLDPRT"))
                    {
                        docType = (swDocumentTypes_e)swDocumentTypes_e.swDocPART;
                    }
                    int errs = 0, wrns = 0;
                    compDoc = swApp.OpenDoc6(path, (int)docType, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errs, ref wrns);
                    if (compDoc == null)
                    {
                        compDoc = (ModelDoc2)comp.GetModelDoc2();
                    }
                    if (compDoc == null)
                    {
                        swApp.SendMsgToUser2("Не могу загрузить " + path, 4, 2);
                        swApp.ExitApp();
                        System.Environment.Exit(0);
                    }
                    configuration = (string)comp.ReferencedConfiguration;
                    swModelDocExt = (ModelDocExtension)compDoc.Extension;
                    prpMgr        = (CustomPropertyManager)swModelDocExt.get_CustomPropertyManager(configuration);

                    prpMgr.Get4("Формат", true, out valOut, out _);
                    component.format = valOut;
                    prpMgr.Get4("Обозначение", true, out valOut, out _);
                    component.designation = valOut;
                    prpMgr.Get4("Наименование", true, out valOut, out _);
                    component.name = valOut;
                    prpMgr.Get4("Примечание", true, out valOut, out _);
                    component.note = valOut;
                    prpMgr.Get4("Раздел", true, out valOut, out _);
                    component.chapter = valOut;
                    prpMgr.Get4("Перв.Примен.", true, out valOut, out _);
                    component.included = valOut;

                    if ((component.chapter == "Стандартные изделия") | (component.chapter == "Прочие изделия"))
                    {
                        prpMgr.Get4("Документ на поставку", true, out valOut, out _);
                        component.doc  = valOut;
                        component.type = component.name.Substring(0, component.name.IndexOf((char)32));
                    }

                    component.x        = Math.Round((aTrans[9] * 1000), 2);
                    component.y        = Math.Round((aTrans[10] * 1000), 2);
                    component.z        = Math.Round((aTrans[11] * 1000), 2);
                    component.rotation = Euler(aTrans);
                    component.quantity = 1;

                    coll.Add(component);
                }
            }

            foreach (Comp k in coll)
            {
                if (k.chapter != "Сборочные единицы" & k.chapter != "Детали" & k.chapter != "Документация" & k.chapter != "Комплекты")
                {
                    k.format = "";
                }

                if (k.chapter != "Сборочные единицы" & k.chapter != "Детали" & k.chapter != "Документация" & k.chapter != "Комплекты" & k.chapter != "Стандартные изделия")
                {
                    k.designation = "";
                }

                if (k.format.Contains("*)"))
                {
                    k.note   = k.format.Substring(2);
                    k.format = "*)";
                }
            }

            return(coll);
        }
Exemplo n.º 7
0
        public string Build(RoofType_e type, int width, int lenght, bool onlyPath)
        {
            string newPartPath = string.Empty;
            string modelName;

            switch (type)
            {
            case  RoofType_e.One:
            case  RoofType_e.Two:
            case  RoofType_e.Three:
            case  RoofType_e.Four:
            case  RoofType_e.Five:
            case  RoofType_e.Six:
                modelName = "15-000";
                break;

            default:
                modelName = "15-000";
                break;
            }



            string newRoofName = "15-0" + type + "-" + width + "-" + lenght;
            string newRoofPath = $@"{RootFolder}{SubjectDestinationFolder}\{newRoofName}.SLDASM";
            bool   IsExistPart = false;

            CheckExistPart(newRoofName + ".SLDASM", out IsExistPart, out newRoofPath);
            var modelRoofPath = $@"{RootFolder}{SourceFolder}\{modelName}.SLDASM";

            solidWorksDocument = SolidWorksAdapter.SldWoksAppExemplare.OpenDoc6(modelRoofPath, (int)swDocumentTypes_e.swDocASSEMBLY,
                                                                                (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel + (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "00", 0, 0);

            AssemblyDoc solidWorcsAssemvlyDocyment = (AssemblyDoc)solidWorksDocument;

            solidWorcsAssemvlyDocyment.ResolveAllLightWeightComponents(false);

            DeleteComponents((int)type);


            #region Сохранение и изменение элементов

            var addwidth  = 100;
            var addwidth2 = 75;
            var type4     = 0;
            var divwidth  = 1;
            if (type == RoofType_e.Two || type == RoofType_e.Six)
            {
                addwidth = 75;
                divwidth = 2;
            }
            if (type == RoofType_e.Four)
            {
                type4     = 170;
                addwidth2 = 170 + 75;
            }

            var          widthD        = (Convert.ToDouble(width) / divwidth + addwidth);
            var          lengthD       = (Convert.ToDouble(lenght) - 28.5);
            const double step          = 200;
            const double step2         = 150;
            var          weldW         = Convert.ToDouble((Math.Truncate(Convert.ToDouble(lenght) / step) + 1));
            var          weldW2        = Convert.ToDouble((Math.Truncate(Convert.ToDouble(lenght) / step2) + 1));
            var          newComponents = new List <FileInfo>();

            //15-001
            SolidWorksAdapter.SldWoksAppExemplare.IActivateDoc2("15-001", true, 0);
            var newPartName = $"15-0{type}-01-{width}-{lenght}";

            CheckExistPart(newPartName, out IsExistPart, out newPartPath);
            if (IsExistPart)
            {
                solidWorksDocument = ((ModelDoc2)(SolidWorksAdapter.SldWoksAppExemplare.ActivateDoc2("15-000.SLDASM", true, 0)));
                solidWorksDocument.Extension.SelectByID2("15-001-1@15-000", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                solidWorcsAssemvlyDocyment.ReplaceComponents(newPartPath, "", true, true);
                SolidWorksAdapter.SldWoksAppExemplare.CloseDoc("15-001.SLDPRT");
            }
            else
            {
                newPartPath = $@"{SourceFolder}\{SubjectDestinationFolder}\{newPartName}.SLDPRT";

                //EditPartParameters("15-001",
                //    $@"{RootFolder}\{SubjectDestinationFolder}\{newPartName}",
                //    new[,]
                //    {
                //        {"D1@Эскиз1",  type ==  RoofType.Five || type == RoofType.Six ? Convert.ToString(140 + lengthD + type4) : Convert.ToString(lengthD + type4)},
                //        {"D2@Эскиз1", Convert.ToString(widthD)},
                //        {"D4@Эскиз27", Convert.ToString(addwidth2-4.62)},
                //        {"D1@Эскиз27", Convert.ToString(90)},
                //        {"D2@Эскиз27", Convert.ToString((75-4.62))},

                //        {"D1@Эскиз24", type ==  RoofType.Five || type == RoofType.Six? Convert.ToString(149.53) : Convert.ToString(9.53)},

                //        {"D1@Кривая2", Convert.ToString(weldW2*1000)},
                //        {"D1@Кривая1", Convert.ToString(weldW*1000)}
                //    } );
                try
                {
                    VentsMatdll(new[] { "1700" }, new[] { "", "Шаргень", "2" }, newPartName);
                }
                catch (Exception e)
                {
                    Patterns.Observer.MessageObserver.Instance.SetMessage(e.ToString());
                }

                SolidWorksAdapter.SldWoksAppExemplare.CloseDoc(newPartName);
            }



            //15-002
            if (type == RoofType_e.Six)
            {
                try
                {
                    SolidWorksAdapter.SldWoksAppExemplare.IActivateDoc2("15-002", true, 0);
                    newPartName = $"15-0{type}-02-{width}-{lenght}";


                    CheckExistPart(newPartName, out IsExistPart, out newPartPath);
                    if (IsExistPart)
                    {
                        solidWorksDocument = ((ModelDoc2)(SolidWorksAdapter.SldWoksAppExemplare.ActivateDoc2("15-000.SLDASM", true, 0)));
                        solidWorksDocument.Extension.SelectByID2("15-002-1@15-000", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                        solidWorcsAssemvlyDocyment.ReplaceComponents(newPartPath, "", true, true);
                        SolidWorksAdapter.SldWoksAppExemplare.CloseDoc("15-002.SLDPRT");
                    }
                    else
                    {
                        newPartPath =
                            $@"{RootFolder}\{SubjectDestinationFolder}\{newPartName}.SLDPRT";
                        //EditPartParameters("15-002",
                        //    $@"{RootFolder}\{SubjectDestinationFolder}\{newPartName}",
                        //    new[,]
                        //    {
                        //        {"D1@Эскиз1",  type ==  RoofType.Five || type ==  RoofType.Six ? Convert.ToString(140 + lengthD + type4) : Convert.ToString(lengthD + type4)},
                        //        {"D2@Эскиз1", Convert.ToString(widthD)},
                        //        {"D4@Эскиз27", Convert.ToString(addwidth2-4.62)},
                        //        {"D1@Эскиз27", Convert.ToString(90)},
                        //        {"D2@Эскиз27", Convert.ToString((75-4.62))},

                        //        {"D2@Эскиз23", type ==  RoofType.Five || type ==  RoofType.Six ? Convert.ToString(165) : Convert.ToString(25)},

                        //        {"D1@Кривая2", Convert.ToString(weldW2*1000)},
                        //        {"D1@Кривая1", Convert.ToString(weldW*1000)}
                        //    } );
                        try
                        {
                            VentsMatdll(new[] { "1700" }, new[] { "", "Шаргень", "2" }, newPartName);
                        }
                        catch (Exception e)
                        {
                            //MessageBox.Show(e.ToString());
                        }

                        SolidWorksAdapter.SldWoksAppExemplare.CloseDoc(newPartName);
                    }
                    solidWorksDocument = ((ModelDoc2)(SolidWorksAdapter.SldWoksAppExemplare.ActivateDoc2("15-000.SLDASM", true, 0)));
                    solidWorksDocument.Extension.SelectByID2("15-001-3@15-000", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    solidWorksDocument.Extension.SelectByID2("ЗеркальныйКомпонент2@15-000", "COMPPATTERN", 0, 0, 0, false, 0, null, 0);
                    solidWorksDocument.EditSuppress2();
                }
                catch (Exception e)
                {
                    Patterns.Observer.MessageObserver.Instance.SetMessage(e.ToString());
                }
            }
            else if (type != RoofType_e.Six)
            {
                solidWorksDocument = ((ModelDoc2)(SolidWorksAdapter.SldWoksAppExemplare.ActivateDoc2("15-000.SLDASM", true, 0)));
                solidWorksDocument.Extension.SelectByID2("15-002-1@15-000", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                solidWorksDocument.EditDelete();
            }

            switch (type)
            {
            case  RoofType_e.Two:
            case  RoofType_e.Six:
                solidWorksDocument.Extension.SelectByID2("Винт самосверл 6-гр.гол с шайбой-33@15-000", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                solidWorksDocument.EditDelete();
                break;

            default:
                solidWorksDocument.Extension.SelectByID2("Винт самосверл 6-гр.гол с шайбой-26@15-000", "COMPONENT", 0, 0, 0, false, 0, null, 0);
                solidWorksDocument.EditDelete();
                break;
            }

            #endregion

            //  GabaritsForPaintingCamera(SolidWorksDocument);
            try
            {
                solidWorksDocument.ForceRebuild3(true);
                //Console.WriteLine("newRoofPath " + newRoofPath);
                solidWorksDocument.SaveAs2(newRoofPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true);
                newComponents.Add(new FileInfo(newRoofPath));
                SolidWorksAdapter.CloseAllDocumentsAndExit();
                //  PDMWebService.Data.PDM.SolidWorksPdmAdapter.Instance.CheckInOutPdm(newComponents, true);
                //Console.WriteLine("RoofBuilder строка 324 пересмотреть CheckInOutPdm");

                foreach (var newComponent in ComponentsPathList)
                {
                    //   ExportXmlSql.Export(newComponent.FullName);
                }
            }
            catch (Exception ex)
            {
                Patterns.Observer.MessageObserver.Instance.SetMessage(ex.ToString());
            }
            if (onlyPath)
            {
                return(newRoofPath);
            }
            //MessageBox.Show(newRoofPath, "Модель построена");

            return(newRoofPath);
        }
 public void ResolveAllComps()
 {
     swMainAssembly.ResolveAllLightWeightComponents(false);
 }