Exemplo n.º 1
0
        public void LoadDataGrid()
        {
            try
            {
                _swmodel = (ModelDoc2)_swapp.ActiveDoc;
                DataGridConfig.Rows.Clear();

                var confarray = _matDll.GetConfigurationNames();

                foreach (var confname in confarray)
                {
                    if (confname == "По умолчанию")
                    {
                        var configuration = (IConfiguration)_swmodel.GetConfigurationByName("По умолчанию");

                        _swapp.SendMsgToUser2("Конфигурация \"По умолчанию\" будет переименована на \"00\"",
                                              (int)swMessageBoxIcon_e.swMbInformation, (int)swMessageBoxBtn_e.swMbOk);
                        configuration.Name = "00";
                    }
                    int n;
                    if (int.TryParse(confname, out n))
                    {
                        var matname = _matDll.GetCustomProperty(confname, null);

                        foreach (var customProperty in matname)
                        {
                            if (customProperty.ColorSQL == "")
                            {
                                DataGridConfig.Rows.Add(ColChB.Selected, confname, customProperty.Name, "Без покрытия");
                            }
                            else
                            {
                                DataGridConfig.Rows.Add(ColChB.Selected, confname, customProperty.Name,
                                                        customProperty.ColorSQL, customProperty.CoatingType, customProperty.CoatingClass);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(@"Конфигурацию """ + confname +
                                        @" ""необходимо переименовать в числовое значение!");

                        Close();
                        return;
                    }
                }

                var activeConfName = _matDll.GetActiveConfigurationName();
                DataGridConfig.Rows[Convert.ToInt32(activeConfName)].Cells[0].Value = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Exemplo n.º 2
0
        private void VentsMatdll(IList<string> materialP1, IList<string> покрытие, string newName)
        {
            ModelDoc2 model = _swApp.ActivateDoc2(newName, true, 0);
            if (model == null) return;            

            try
            {
                MessageBox.Show(newName);
                
                var setMaterials = new SetMaterials();
                ToSQL.Conn = Settings.Default.ConnectionToSQL;
                var toSql = new ToSQL();
                
                //MessageBox.Show($"Conn - {ToSQL.Conn} SetMaterials {setMaterials == null} toSql - {toSql == null} _swApp {_swApp == null} levelId - {Convert.ToInt32(materialP1[0])}");

                setMaterials?.ApplyMaterial("", "00", Convert.ToInt32(materialP1[0]), _swApp);
                model?.Save();

                foreach (var confname in setMaterials.GetConfigurationNames(_swApp))
                {
                    foreach (var matname in setMaterials.GetCustomProperty(confname, _swApp))
                    {
                        toSql.AddCustomProperty(confname, matname.Name, _swApp);
                    }
                }

                if (покрытие != null)
                {
                    if (покрытие[1] != "0")
                    {
                        setMaterials.SetColor("00", покрытие[0], покрытие[1], покрытие[2], _swApp);
                    }
                    _swApp.IActiveDoc2.Save();
                }

                try
                {
                    string message;
                    setMaterials.CheckSheetMetalProperty("00", _swApp, out message);
                    if (message != null)
                    {
                       // MessageBox.Show(message, newName + " 858 ");
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show($"{newName}\n{e.Message}\n{e.StackTrace}", "VentsMatdll");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"{newName}\n{e.Message}\n{e.StackTrace}\n{newName}", "VentsMatdll 2");
            }

            GabaritsForPaintingCamera(model);

            model?.Save();
        }
Exemplo n.º 3
0
        public List <SldWorksPropClass> GetSldWorksListProp()
        {
            // MessageBox.Show(SwModel.GetPathName());
            var columnRow = new List <SldWorksPropClass>();

            try
            {
                string[] ConfigArray = SwModel.GetConfigurationNames();

                for (var i = 0; i <= ConfigArray.GetUpperBound(0); i++)
                {
                    Configuration swConf = SwModel.GetConfigurationByName(ConfigArray[i]);

                    if (swConf.IsDerived())
                    {
                        continue;
                    }
                    var customProp = SwModel.Extension.CustomPropertyManager[ConfigArray[i]];

                    string description;
                    string valOut;
                    string note;
                    //string matId;
                    string code1c;
                    string lenght;
                    string width;
                    string summ;

                    //const string propMatId = "MaterialID";
                    const string propDescription = "Наименование";
                    const string propLinght      = "Длина";
                    const string propWight       = "Ширина";
                    const string propSumm        = "Количество";
                    const string propNote        = "Примечание";
                    const string propCode1C      = "Код материала";

                    //customProp.Get4(propMatId, true, out valOut, out matId);
                    customProp.Get4(propDescription, true, out valOut, out description);
                    customProp.Get4(propLinght, true, out valOut, out lenght);
                    customProp.Get4(propWight, true, out valOut, out width);
                    customProp.Get4(propSumm, true, out valOut, out summ);
                    customProp.Get4(propNote, true, out valOut, out note);
                    customProp.Get4(propCode1C, true, out valOut, out code1c);

                    //if (matId == "")
                    //{
                    //    MessageBox.Show("Примените материал на модель!");
                    //    Close();
                    //    break;
                    //}

                    if (SwModel.GetType() == (int)swDocumentTypes_e.swDocPART)
                    {
                        foreach (var matName in _sM.GetCustomProperty(ConfigArray[i], SwApp))
                        {
                            var sldWorksPropArray = new SldWorksPropClass
                            {
                                Config      = ConfigArray[i],
                                Description = _sM.CheckType == 0 ? description : matName.Name,
                                //Description = matName.Name == "" ? "" : matName.Name,
                                //MatId = matId == "" ? "" : matId,
                                Code1C = code1c == "" ? "" : code1c,
                                Length = lenght == "" ? "" : lenght,
                                Width  = width == "" ? "" : width,
                                Summ   = summ == "" ? "" : summ,
                                Note   = note == "" ? "" : note
                            };

                            columnRow.Add(sldWorksPropArray);
                        }
                    }

                    if (SwModel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY)
                    {
                        var sldWorksPropArray = new SldWorksPropClass
                        {
                            Config      = ConfigArray[i],
                            Description = description,
                            Code1C      = code1c == "" ? "" : code1c,
                            Length      = lenght == "" ? "" : lenght,
                            Width       = width == "" ? "" : width,
                            Summ        = summ == "" ? "" : summ,
                            Note        = note == "" ? "" : note
                        };

                        columnRow.Add(sldWorksPropArray);
                    }



                    Debug.Print("Примечание - {0}, Материал ID - {1}, Длина - {2}, Ширина - {3}, Количество - {4}", note, "matId", lenght, width, summ);
                }
                return(columnRow);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Message: {ex.Message}\r\nTargetSite: {ex.TargetSite}\r\nStackTrace: {ex.StackTrace}");
            }

            return(columnRow);
        }