예제 #1
0
        public void SetMaterial()
        {
            try
            {
                //ToSQL.Conn = _con.Con;

                if (MatTree.SelectedNode == null)
                {
                    MessageBox.Show(@"Выберите материал для применения!");
                    return;
                }

                var id = MatTree.SelectedNode.Name;

                dynamic checkedRows = (from rows in DataGridConfig.Rows.Cast <DataGridViewRow>()
                                       where Convert.ToBoolean(rows.Cells[0].Value.ToString())
                                       select rows).ToList();

                foreach (DataGridViewRow row in checkedRows)
                {
                    var confname = row.Cells[1].Value.ToString();

                    //_checkModelClass.SplitConfigurations(confname);

                    if (_checkModelClass.CheckSheetMetal())
                    {
                        string sheetMetalMessage;
                        _matDll.CheckSheetMetalProperty(confname, null, out sheetMetalMessage);
                        if (!(string.IsNullOrEmpty(sheetMetalMessage)))
                        {
                            MessageBox.Show(sheetMetalMessage);
                        }
                    }
                    _matDll.ApplyMaterial("", confname, Convert.ToInt32(id), null);
                }

                foreach (DataGridViewRow row in checkedRows)
                {
                    var confname = row.Cells[1].Value.ToString();

                    _matDll.SetColor(confname, Convert.ToString(CboColor.SelectedValue),
                                     Convert.ToString(CboType.SelectedValue), Convert.ToString(CboClass.SelectedValue), null);
                }

                foreach (var confname in _matDll.GetConfigurationNames())
                {
                    foreach (var matname in _matDll.GetCustomProperty(confname, null))
                    {
                        //TODO: входная строка, MaterialsDLL
                        _sqlDll.AddCustomProperty(confname, matname.Name, null);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "; " + ex.StackTrace);
            }
        }
예제 #2
0
        protected virtual void EditPartParameters(string partName, string newPath, int materialID)
        {
            foreach (var eachParameter in parameters)
            {
                try
                {
                    Dimension myDimension = (SolidWorksDocument.Parameter(eachParameter.Key + "@" + partName + ".SLDPRT")) as Dimension;
                    myDimension.SystemValue = eachParameter.Value / 1000;
                }
                catch (Exception ex)
                {
                    //System.Windows.Forms.MessageBox.Show(eachParameter.Key + "@" + partName);
                    MessageObserver.Instance.SetMessage(ex.ToString(), MessageType.Error);
                }
            }
            this.parameters.Clear();

            SolidWorksDocument = SolidWorksAdapter.AcativeteDoc(partName);
            if (SolidWorksDocument != null)
            {
                SolidWorksDocument.ForceRebuild3(true);

                toSQL.AddCustomProperty("", materialID, SolidWorksAdapter.SldWoksAppExemplare);
                SolidWorksDocument.Extension.SaveAs(newPath + ".SLDPRT", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent
                                                    + (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced + (int)swSaveAsOptions_e.swSaveAsOptions_UpdateInactiveViews, null, ref errors, warnings);

                InitiatorSaveExeption(errors, warnings, newPath);
                SolidWorksAdapter.CloseDocument(SolidWorksDocument);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Не удалось преобразовать деталь " + partName);
            }

            SolidWorksAdapter.SldWoksAppExemplare.DocumentVisible(false, 2);
            SolidWorksAdapter.SldWoksAppExemplare.DocumentVisible(false, 1);
        }
예제 #3
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();
        }