当前位置: 首页>>代码示例>>C#>>正文


C# ModelDoc2.Save方法代码示例

本文整理汇总了C#中ModelDoc2.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ModelDoc2.Save方法的具体用法?C# ModelDoc2.Save怎么用?C# ModelDoc2.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelDoc2的用法示例。


在下文中一共展示了ModelDoc2.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetObjectValue

        public bool SetObjectValue(ModelDoc2 inModel, string inName, int inType, double inVal, bool noArtIfSuppressed = false)
        {
            object swObj;
            Dimension swDim;
            Feature swFeature;
            Component2 swComp;
            bool ret = false;

            if (GetObjectByName(inModel, inName, inType, out swObj))
            {
                double dTestVal;
                switch (inType)
                {
                    case 14:
                        swDim = (Dimension)swObj;
                        dTestVal = swDim.GetSystemValue2("") * 1000;

                        if (dTestVal != inVal)
                        {
                            ret = (swDim.SetSystemValue2(inVal / 1000,
                                                         (int)
                                                         swSetValueInConfiguration_e.swSetValue_InAllConfigurations) ==
                                   (int)swSetValueReturnStatus_e.swSetValue_Successful);
                        }
                        else
                            ret = true;
                        break;

                    case 22:
                        swFeature = (Feature)swObj;
                        dTestVal = (swFeature.IsSuppressed() ? 0 : 1);

                        if (dTestVal != inVal)
                        {
                            //ret = swFeature.SetSuppression(inVal == 0 ? (int) swFeatureSuppressionAction_e.swSuppressFeature : (int)swFeatureSuppressionAction_e.swUnSuppressFeature);
                            ret =
                                swFeature.SetSuppression2(
                                    inVal == 0
                                        ? (int)swFeatureSuppressionAction_e.swSuppressFeature
                                        : (int)swFeatureSuppressionAction_e.swUnSuppressFeature,
                                    (int)swInConfigurationOpts_e.swAllConfiguration, inModel.GetConfigurationNames());

                            #region ������ ��������

                            Component2 newComp = null;

                            var config = inModel.IGetActiveConfiguration();
                            if (config != null)
                            {
                                swComp = config.IGetRootComponent2();
                                if (swComp != null)
                                {
                                    var outComps = new LinkedList<Component2>();
                                    if (GetComponents(swComp, outComps, false, false))
                                    {
                                        foreach (var component2 in outComps)
                                        {
                                            var mod = component2.IGetModelDoc();
                                            if (mod != null)
                                            {
                                                var texture = component2.GetTexture("");
                                                if (mod.GetType() == (int)swDocumentTypes_e.swDocPART &&
                                                    texture != null)
                                                {
                                                    newComp = component2;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (newComp != null)
                            {
                                inModel.Save();
                                if (newComp.Select(false))
                                    ((AssemblyDoc)inModel).ComponentReload();
                            }

                            #endregion
                        }
                        else
                            ret = true;
                        break;

                    case 20:
                        swComp = (Component2)swObj;
                        try
                        {
                            if ((swComp.IsSuppressed() ? 0 : 1) == inVal)
                            {
                                ret = true;
                            }
                            else
                            {
                                int k = inVal == 0
                                            ? (int)swComponentSuppressionState_e.swComponentSuppressed
                                            : (int)swComponentSuppressionState_e.swComponentFullyResolved;

                                bool isCavity = false;
                                if (inVal == 0)
//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:SwAddin.cs

示例2: RenameCustomProperty

 private void RenameCustomProperty(ModelDoc2 model, string conf, string from, string to)
 {
     string val1, val2;
     model.Extension.get_CustomPropertyManager("").Get2(from, out val1, out val2);
     string value = val1;//model.GetCustomInfoValue(conf, from);
     if (!string.IsNullOrEmpty(value))
     {
         model.DeleteCustomInfo2(conf, from);
         model.AddCustomInfo3(conf, to, (int)swCustomInfoType_e.swCustomInfoText, value);
         model.Save();
     }
 }
开发者ID:digger1985,项目名称:MyCode,代码行数:12,代码来源:SwAddin.cs

示例3: RecopyHeare

        public static void RecopyHeare(SwAddin swAddin, ISldWorks swApp,ModelDoc2 swModelDoc)
        {
            try
            {
            SwAddin.IsEventsEnabled = false;
            swModelDoc.Save();
            ModelDocExtension swModelDocExt = default(ModelDocExtension);
            PackAndGo swPackAndGo = default(PackAndGo);
            Dictionary<string,string> filesToHideAndShow = new Dictionary<string, string>();
            WaitTime.Instance.ShowWait();
            WaitTime.Instance.SetLabel("Отрыв сборки от библиотеки.");
            int warnings = 0;
            int errors = 0;
            string _openFile = swModelDoc.GetPathName();

            swAddin.currentPath = string.Empty;
            swApp.CloseAllDocuments(true);
            if (!Directory.Exists("C:\\Temp"))
                Directory.CreateDirectory("C:\\Temp");
            string tempDir = Path.Combine("C:\\Temp", Path.GetFileNameWithoutExtension(_openFile));
            if (Directory.Exists(tempDir))
            {
                Directory.Delete(tempDir, true);
            }
            Directory.CreateDirectory(tempDir);
            string fileToOpenTemp = Path.Combine(tempDir, Path.GetFileName(_openFile));
            //File.Copy(_openFile, fileToOpenTemp);
            Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(Path.GetDirectoryName(_openFile), tempDir);
            if (!File.Exists(fileToOpenTemp))
            {
                throw new Exception("Ошибка. Не найден файл: " + fileToOpenTemp);
            }
            swAddin.DetachEventHandlers();
            swModelDoc = (ModelDoc2)swApp.OpenDoc6(fileToOpenTemp, (int)swDocumentTypes_e.swDocASSEMBLY,
                                                    (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors,
                                                    warnings);
            swAddin.AttachEventHandlers();
            try
            {
                foreach (var file in Directory.GetFiles(Path.GetDirectoryName(_openFile)))
                {
                    File.Delete(file);
                }
                foreach (var directory in Directory.GetDirectories(Path.GetDirectoryName(_openFile)))
                {
                    Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(directory, Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs, Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
                    //Directory.Delete(directory, true);
                }
            }
            catch (Exception e)
            {
                Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory( tempDir,Path.GetDirectoryName(_openFile),true);
                swAddin.DetachEventHandlers();
                swApp.CloseAllDocuments(true);
                swModelDoc = (ModelDoc2)swApp.OpenDoc6(_openFile, (int)swDocumentTypes_e.swDocASSEMBLY,
                                                        (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors,
                                                        warnings);
                swAddin.AttachEventHandlers();
                MessageBox.Show(@"Из-за ошибки: """ + e.Message + @""" не удалось оторвать проект. Перезапустите SW и попробуйте еще раз.");
                return;
            }

            //File.Delete(_openFile);
            swModelDocExt = (ModelDocExtension)swModelDoc.Extension;

            swPackAndGo = (PackAndGo)swModelDocExt.GetPackAndGo();

            //swModelDoc = (ModelDoc2)swApp.OpenDoc6(openFile, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);
            //swModelDocExt = (ModelDocExtension)swModelDoc.Extension;

            int namesCount = swPackAndGo.GetDocumentNamesCount();

            object fileNames;
            object[] pgFileNames = new object[namesCount - 1];
            bool status = swPackAndGo.GetDocumentNames(out fileNames);
            string[] newFileNames = new string[namesCount];
            string[] rFileNames1 = fileNames as string[];
            if (rFileNames1 == null)
                throw new Exception("Не удалось оторвать заказ.");
            string[] rFileNames = new string[rFileNames1.Length];

            for (int ii = 0; ii < rFileNames1.Length;ii++ )
            {
                var tt1 = Microsoft.VisualBasic.FileSystem.Dir(rFileNames1[ii]);
                if (tt1==null)
                    tt1 = Microsoft.VisualBasic.FileSystem.Dir(rFileNames1[ii], Microsoft.VisualBasic.FileAttribute.Hidden);
                rFileNames[ii] = Path.Combine(Path.GetDirectoryName(rFileNames1[ii]),tt1);
            }
            //удалить неактуальные программы..
            DeleteXmlFiles(tempDir, rFileNames,_openFile);
            //bool isAuxiliary = (swCompModel.get_CustomInfo2("", "Auxiliary") == "Yes");
            //bool isAccessory = (swCompModel.get_CustomInfo2("", "Accessories") == "Yes");

            //string strSubCompNewFileName;
            //if (GetComponentNewFileName(swModel, isAuxiliary, isAccessory,
            //                            isFirstLevel, strSubCompOldFileNameFromModel,
            //                            out strSubCompNewFileName))
            //{
            //}

//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:frmCopyProject.cs


注:本文中的ModelDoc2.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。