示例#1
0
        public void ClearProps(ModelDoc2 md)
        {
            CustomPropertyManager glP = md.Extension.get_CustomPropertyManager(string.Empty);
            int res;

            for (int i = 1; i <= Properties.Settings.Default.RevLimit; i++)
            {
                res = glP.Delete2("REVISION " + (char)(i + 65));
                res = glP.Delete2("ECO " + i.ToString());
                res = glP.Delete2("DESCRIPTION " + i.ToString());
                res = glP.Delete2("LIST " + i.ToString());
                res = glP.Delete2("DATE " + i.ToString());
            }
        }
示例#2
0
        /// <summary>
        /// Deletes the prop from the selected ModelDoc2 object.
        /// </summary>
        /// <param name="md">A ModelDoc2 object.</param>
        public void Del(ModelDoc2 md)
        {
            Configuration cf = md.ConfigurationManager.ActiveConfiguration;

            CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty);
            CustomPropertyManager scpm;

            if (cf != null)
            {
                scpm = md.Extension.get_CustomPropertyManager(cf.Name);
            }
            else
            {
                scpm = md.Extension.get_CustomPropertyManager(string.Empty);
            }

            int res;

            if (this.Global)
            {
                res = gcpm.Delete2(Name);
            }
            else
            {
                res = scpm.Delete2(Name);
            }
        }
示例#3
0
        /// <summary>
        /// Deletes the prop from the SW doc, assigning the SwApp object.
        /// </summary>
        /// <param name="sw"></param>
        public void Del(SldWorks sw)
        {
            if (sw != null)
            {
                SwApp = sw;
                ModelDoc2     md = (ModelDoc2)sw.ActiveDoc;
                Configuration cf = md.ConfigurationManager.ActiveConfiguration;

                CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty);
                CustomPropertyManager scpm;
                if (cf != null)
                {
                    scpm = md.Extension.get_CustomPropertyManager(cf.Name);
                }
                else
                {
                    scpm = md.Extension.get_CustomPropertyManager(string.Empty);
                }

                int res;

                if (Global)
                {
                    res = gcpm.Delete2(Name);
                }
                else
                {
                    res = scpm.Delete2(Name);
                }
            }
            else
            {
                throw new NullReferenceException("sw is null");
            }
        }
        /// <summary>
        /// Метод удаляет свойство в соответствующую конфигурацию
        /// объекта и в ModelDoc2
        /// </summary>
        /// <param name="nameConfig"></param>
        /// <param name="prop"></param>
        /// <returns></returns>
        public int Remove(string nameConfig, SwProperty prop)
        {
            if (prop == null)
            {
                throw new System.ArgumentNullException(nameof(prop));
            }

            if (!_ConfigPropertys.ContainsKey(nameConfig))
            {
                throw new KeyNotFoundException(nameof(prop));
            }

            // Выбираем исполнение в котором собираемся менять свойства
            _customPropManager = SwModel.Extension.CustomPropertyManager[nameConfig];

            //Удаляем из списка свойств.
            if (_ConfigPropertys[nameConfig].Remove(prop))
            {
                //Удаляем свойство из модели SolidWorks
                return(_customPropManager.Delete2(prop.Name));
            }
            else
            {
                return(1);
            }
        }
示例#5
0
        /// <summary>
        /// Удаляет свойства, если они не в своей категории
        /// </summary>
        public static void FixPropertys()
        {
            string ValOut;
            string ResValOut;
            bool   WasResolved;

            cust  = swModel.Extension.CustomPropertyManager[""];
            cust2 = swModel.Extension.CustomPropertyManager[EditProp.configuracione];

            cust.Delete2("Обозначение");
            cust.Delete2("Наименование");
            cust.Delete2("Наименование_ФБ");
            cust.Delete2("Number");
            cust.Delete2("RenameSWP");
            cust.Delete2("DescriptionEng");
            cust.Delete2("Сборка");
            cust.Delete2("Примечание");
            cust.Delete2("Формат");
            cust.Delete2("DrawnBy");

            cust2.Get5("Проверил", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.ChechedBy = ResValOut;
            cust2.Delete2("Проверил");
            cust.Add3("Проверил", 30, Propertiy.ChechedBy, (int)swCustomPropertyAddOption_e.swCustomPropertyOnlyIfNew);

            cust2.Get5("Утвердил", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.ApprovedBy = ResValOut;
            cust2.Delete2("Утвердил");
            cust.Add3("Утвердил", 30, ResValOut, (int)swCustomPropertyAddOption_e.swCustomPropertyOnlyIfNew);

            cust2.Get5("Техконтроль", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.TControl = ResValOut;
            cust2.Delete2("Техконтроль");
            cust.Add3("Техконтроль", 30, ResValOut, (int)swCustomPropertyAddOption_e.swCustomPropertyOnlyIfNew);

            cust2.Get5("Масса_Таблица", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.Weight = ResValOut;
            cust2.Delete2("Масса_Таблица");
            cust2.Add3("Масса", 30, ResValOut, (int)swCustomPropertyAddOption_e.swCustomPropertyOnlyIfNew);


            cust2.Delete2("CheckedBy");
            cust2.Delete2("EngineeringApproval");
            swModel.ForceRebuild3(false);
        }
示例#6
0
        public void ClearProps()
        {
            ModelDoc2             md  = (ModelDoc2)this._swApp.ActiveDoc;
            CustomPropertyManager glP = md.Extension.get_CustomPropertyManager(string.Empty);

            string[] ss = (string[])glP.GetNames();

            if (ss != null)
            {
                foreach (string s in ss)
                {
                    glP.Delete2(s);
                }
            }
        }
示例#7
0
        public void ClearProps(ModelDoc2 md)
        {
            if (md.GetType() == (int)swDocumentTypes_e.swDocDRAWING)
            {
                CustomPropertyManager glP = md.Extension.get_CustomPropertyManager(string.Empty);
                string[] ss = (string[])glP.GetNames();

                if (ss != null)
                {
                    foreach (string s in ss)
                    {
                        glP.Delete2(s);
                    }
                }
            }
        }
        public void WriteCustomProp(DataRow dr)
        {
            string thisConfigName = (string)dr["configname"];

            if (thisConfigName != "" && !configNames.Contains(thisConfigName))
            {
                string strExcept = String.Format("Config name {0} is not in this model", thisConfigName);
                throw new Exception(strExcept);
            }
            CustomPropertyManager swCustPropMgr = (CustomPropertyManager)swModelDocExt.get_CustomPropertyManager(thisConfigName);

            // Get existing property names
            string[]      nameArray = swCustPropMgr.GetNames();
            List <string> propNames = new List <string>();

            if (nameArray != null)
            {
                propNames.AddRange(swCustPropMgr.GetNames());
            }

            // Check for a part number
            bool hasPartNum = dr["PartNum"].ToString() != "";

            // So far, we always store custom properties as text (i.e. swCustomInfoType_e.swCustomInfoText)
            foreach (DataRow drField in propScaffold.FieldDefs.Select("sw_prop is not null"))
            {
                string propName  = drField["sw_prop"].ToString();
                string fieldName = drField["field"].ToString();
                string typeName  = drField["dt_type"].ToString();
                if (CheckPropDefaultValue(dr[fieldName], typeName))
                {
                    // Remove the custom property
                    swCustPropMgr.Delete2(propName);
                }
                else
                {
                    // Add the custom property
                    swCustPropMgr.Add3(
                        propName,
                        propScaffold.PropTypes[propName],
                        dr[fieldName].ToString(),
                        (int)swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd);
                }
            }

            swMainModel.SetSaveFlag();
        }
        private void Nettoyer()
        {
            WindowLog.Ecrire("Nettoyer les modeles :");
            List <ModelDoc2> ListeMdl = new List <ModelDoc2>(MdlBase.pListerComposants().Keys);

            foreach (var mdl in ListeMdl)
            {
                if (mdl.TypeDoc() != eTypeDoc.Piece)
                {
                    continue;
                }

                mdl.eActiverManager(false);

                foreach (Configuration Cf in mdl.eListeConfigs(eTypeConfig.Depliee))
                {
                    Cf.eSupprimerConfigAvecEtatAff(mdl);
                }

                mdl.eActiver(swRebuildOnActivation_e.swRebuildActiveDoc);
                {
                    mdl.ePropSuppr(CONST_PRODUCTION.ID_PIECE);
                    mdl.ePropSuppr(CONST_PRODUCTION.PIECE_ID_DOSSIERS);
                    mdl.ePropSuppr(CONST_PRODUCTION.MAX_INDEXDIM);

                    // On supprime la definition du bloc
                    SupprimerDefBloc(mdl, CheminBlocEsquisseNumeroter());
                }

                foreach (var cfg in mdl.eListeNomConfiguration())
                {
                    mdl.ShowConfiguration2(cfg);
                    mdl.EditRebuild3();
                    var Piece = mdl.ePartDoc();

                    mdl.ePropSuppr(CONST_PRODUCTION.ID_CONFIG, cfg);
                    mdl.ePropSuppr(CONST_PRODUCTION.CONFIG_ID_DOSSIERS, cfg);

                    foreach (var f in Piece.eListeDesFonctionsDePiecesSoudees())
                    {
                        CustomPropertyManager PM = f.CustomPropertyManager;
                        PM.Delete2(CONSTANTES.REF_DOSSIER);
                        PM.Delete2(CONSTANTES.DESC_DOSSIER);
                        PM.Delete2(CONSTANTES.NOM_DOSSIER);

                        String ValParDefaut = mdl.Extension.GetUserPreferenceString((int)swUserPreferenceStringValue_e.swSheetMetalDescription, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified);
                        PM.ePropAdd(CONSTANTES.DESC_DOSSIER, ValParDefaut);
                    }
                }

                mdl.eActiverManager(true);

                mdl.eFermerSiDifferent(MdlBase);
            }

            int errors   = 0;
            int warnings = 0;

            MdlBase.Save3((int)swSaveAsOptions_e.swSaveAsOptions_Silent + (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced, ref errors, ref warnings);

            WindowLog.Ecrire("- Nettoyage terminé");
        }