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


C# ModelDoc2.GetPathName方法代码示例

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


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

示例1: KitchenModule

 public KitchenModule(ModelDoc2 _rootModel, Component2 _swRootComponent, SwAddin _swAddin, ModelDoc2 _swModel)
 {
     RootModel = _rootModel;
     swRootComponent = _swRootComponent;
     measure = RootModel.Extension.CreateMeasure();
     swAddin = _swAddin;
     swModel = _swModel;
     rootName = Path.GetFileNameWithoutExtension(RootModel.GetPathName());
 }
开发者ID:digger1985,项目名称:MyCode,代码行数:9,代码来源:KitchenModule.cs

示例2: SomeLogicChanges

        private bool SomeLogicChanges(ModelDoc2 swModel)
        {
            XmlNodeList views = null;
            XmlNode F1View = null, F6View = null;
            XmlNodeList list = null;
            if (this._cxml.ChildNodes[0].Attributes["Name"].Value.Contains("8504F_Панель вкладная 00AA") && Properties.Settings.Default.DeleteDraftIfStandart)
            {
                foreach (XmlNode node3 in this._cxml.ChildNodes[0].ChildNodes)
                {
                    list = node3.SelectNodes("View");
                    if (list.Count > 0)
                    {
                        foreach (XmlNode node4 in list)
                        {
                            if (node4.Attributes["Name"].Value == "F1")
                            {
                                double result = 0.0;
                                double num2 = 0.0;
                                if ((double.TryParse(node4.ChildNodes[0].Attributes["Y"].Value, out result) && double.TryParse(node4.ChildNodes[1].Attributes["Y"].Value, out num2)) && ((((result >= 140.0) && (result < 601.0)) && (result == (num2 + 50.0))) || (((result > 69.0) && (result < 140.0)) && (result == (num2 * 2.0)))))
                                {
                                    bool flag2 = true;
                                    if (MessageBox.Show("Данная деталь совпадает со стандртной типологией, на которую существует программа на обработку, поэтому чертеж на нее является излишним.Удалить чертеж на данную деталь ?", "MrDoors", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                                    {
                                        break;
                                    }
                                    try
                                    {
                                        string pathName = swModel.GetPathName();
                                        string path = string.Format("{0}{1}", pathName.Substring(0, pathName.Length - 6), "SLDASM");
                                        if (File.Exists(path))
                                        {
                                            int errors = 0;
                                            int warnings = 0;
                                            ModelDoc2 model = this._swApp.OpenDoc6(path, 2, 1, "", ref errors, ref warnings);
                                            this._swAdd.SetModelProperty(model, "Required Draft", "", swCustomInfoType_e.swCustomInfoText, "No", true);
                                            model.Save2(true);
                                        }
                                        if (File.Exists(pathName))
                                        {
                                            this._swApp.CloseDoc(pathName);
                                            File.Delete(pathName);
                                        }
                                        this.DrawRenumering();
                                        flag2 = false;
                                    }
                                    catch (Exception)
                                    {
                                    }
                                    return flag2;
                                }
                            }
                        }
                    }
                }
            }
            List<XmlNode> allViews = new List<XmlNode>();
            foreach (XmlNode sheet in _cxml.ChildNodes[0].ChildNodes)
            {
                views = sheet.SelectNodes("View");
                if (views.Count > 0)
                {
                    foreach (XmlNode view in views)
                    {
                        allViews.Add(view);
                        if (view.Attributes["Name"].Value == "F1")
                            F1View = view;
                        if (view.Attributes["Name"].Value == "F6")
                            F6View = view;
                    }
                }
            }

            if (F1View != null)
            {
                double currentDepth = 0;
                try
                {
                    double.TryParse(F1View.ChildNodes[0].Attributes["Z"].Value, out currentDepth);
                }
                catch
                { }
                foreach (XmlNode node in F1View.ChildNodes)
                {
                    string X = node.Attributes["X"].Value;
                    string Y = node.Attributes["Y"].Value;
                    //string xPath = string.Format("*[@X={0} and @Y={1}]", X, Y);
                    List<XmlNode> correlateNodes = new List<XmlNode>();
                    foreach (XmlNode child in F1View.ChildNodes)
                    {
                        if (child.Attributes["Depth"] == null)
                            continue;
                        if (child.Attributes["X"].Value == X && child.Attributes["Y"].Value == Y)
                            correlateNodes.Add(child);
                    }
                    //var correlateNodes = F1View.SelectNodes(xPath);
                    XmlNode sequentiallyNode = null;
                    if (correlateNodes.Count > 1)
                    {
                        //тут мы определили что есть минимум 2 присадки с одинаковыми координатами
                        //проверить что хотябы одна из них сквозная
//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:DimensionDraft.cs

示例3: SetMeterial

        /// <summary>
        /// Задает материал для детали из сборки (если задан componentId) либо по имени детали
        /// </summary>
        /// <param name="materialName">Материал (код или наименование по базе)</param>
        /// <param name="swDoc">Деталь</param>
        /// <param name="componentId">The component identifier.</param>
        private static void SetMeterial(string materialName, ModelDoc2 swDoc, string componentId)
        {
            if (componentId != "")
            {
                try
                {
                    //"ВНС[email protected]ВНС-901.43.200/ВНС[email protected]ВНС-901.43.230"
                    swDoc.Extension.SelectByID2(componentId, "COMPONENT", 0, 0, 0, false, 0, null, 0);
                    var comp = swDoc.ISelectionManager.GetSelectedObject3(1);
                    var matChangingModel = comp.GetModelDoc();
                    const string configName = "";
                    const string databaseName = "materialsXML.sldmat";
                    matChangingModel.SetMaterialPropertyName2(configName, databaseName, AddMaterialtoXml(materialName));
                    Логгер.Информация(string.Format("Для компонента {1} применен материал {0} ", AddMaterialtoXml(materialName), componentId), null, "", "SetMeterial");
                }
                catch (Exception ex)
                {
                    Логгер.Ошибка($"Не удалось применить материал {AddMaterialtoXml(materialName)} для компонента {componentId}. {ex.Message}",
                        ex.StackTrace, null, "SetMeterial");
                }
            }

            if (componentId == "")
            {
                try
                {
                    var swPart = ((PartDoc) (swDoc));
                    const string configName = "";
                    const string databaseName = "materialsXML.sldmat";
                    swPart.SetMaterialPropertyName2(configName, databaseName, AddMaterialtoXml(materialName));

                    Логгер.Информация(
                        string.Format("Для детали {1} применен материал {0} ", AddMaterialtoXml(materialName),
                            swDoc.GetPathName()), null, "", "SetMeterial");
                }
                catch (Exception ex)
                {
                    Логгер.Ошибка($"Не удалось применить материал {AddMaterialtoXml(materialName)} для детали {componentId}. {ex.Message}", ex.StackTrace, null, "SetMeterial");
                }
            }

            File.Delete(@"C:\Program Files\SW-Complex\materialsXML.sldmat");
        }
开发者ID:GitHubVents,项目名称:AirVentsCad,代码行数:49,代码来源:GenerateUnit50.cs

示例4: SetColorProperty

        private bool SetColorProperty(ModelDoc2 inModel, string colorProp, OleDbConnection oleDb, string colorName,
            string column, OleDbConnection oleDbDecorDef)
        {
            bool isColorChanged = false;
            if (colorProp != "")
            {
                var names = (string[])inModel.GetCustomInfoNames2("");
                if (names.Contains(colorProp))
                {
                    isColorChanged = _mSwAddin.SetModelProperty(inModel, colorProp, "",
                                                                swCustomInfoType_e.swCustomInfoText,
                                                                colorName, true);
                    if (oleDbDecorDef != null)
                    {
                        string fullDecorName = string.Empty;
                        string[] restrictionValues = new string[3] { null, null, "decornames" };
                        DataTable schemaInformation = oleDbDecorDef.GetSchema("Tables", restrictionValues);
                        if (schemaInformation.Rows.Count == 0)
                            fullDecorName = string.Empty;
                        else
                        {
                            string selectStr = @"select * from decornames where FILEJPG = """ +
                                               colorName + @"""";
                            var cmDecorDef = new OleDbCommand(selectStr, oleDbDecorDef);
                            var rdDecorDef = cmDecorDef.ExecuteReader();
                            while (rdDecorDef.Read())
                            {
                                fullDecorName = rdDecorDef["DecorName"].ToString();
                            }
                            schemaInformation.Dispose();
                            cmDecorDef.Dispose();
                            rdDecorDef.Close();
                        }
                        int index;
                        if (int.TryParse(colorProp.Substring(colorProp.Length - 1, 1), out index))
                            _mSwAddin.SetModelProperty(inModel, "ColorName" + index.ToString(), "",
                                                       swCustomInfoType_e.swCustomInfoText,
                                                       fullDecorName, true);
                    }

                }
            }
            else
            {
                if (column == "Part Color Priority")
                    MessageBox.Show(@"В файле " + Environment.NewLine + oleDb.DataSource + Environment.NewLine +
                                @" в столбце 'Part Color Priority', Element: " +
                                Path.GetFileNameWithoutExtension(
                                    _mSwAddin.GetModelNameWithoutSuffix(inModel.GetPathName()))
                                + @" ошибка!", _mSwAddin.MyTitle, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                else
                    MessageBox.Show(@"В файле " + Environment.NewLine + oleDb.DataSource + Environment.NewLine +
                                @" в столбце '" + column + @"' ошибка!", _mSwAddin.MyTitle, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            return isColorChanged;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:58,代码来源:frmSetParameters.cs

示例5: ReloadAllSetParameters


//.........这里部分代码省略.........
                                #region Размеры

                                #region Считывание данных из objects

                                int k = 1;
                                var dictWithDiscretValues = new Dictionary<string, List<int>>();

                                while (rd.Read())
                                {
                                    if (captConfigBool && rd["captConf"] != null && rd["captConf"].ToString() != "all" && rd["captConf"].ToString() != currentConf && !string.IsNullOrEmpty(rd["captConf"].ToString()))
                                        continue;
                                    if (rd["caption"].ToString() == null || rd["caption"].ToString() == "" ||
                                        rd["caption"].ToString().Trim() == "")
                                        continue;

                                    #region Обработка поля mainasmconf

                                    if (isAsmConfig)
                                    {
                                        var neededConf = rd["mainasmconf"].ToString();
                                        bool isNeededConf = neededConf.Split('+').Select(v => v.Trim()).Any(
                                            f => f == currentConf);
                                        if (neededConf == "all")
                                            isNeededConf = true;
                                        if (!isNeededConf)
                                            continue;
                                    }

                                    #endregion

                                    string strObjName = rd["name"].ToString();

                                    double strObjVal;
                                    if (_swSelModel.GetPathName().Contains("_SWLIB_BACKUP"))
                                    {
                                        string pn = Path.GetFileNameWithoutExtension(_swSelModel.GetPathName());
                                        string last3 = pn.Substring(pn.Length - 4, 4);
                                        string[] arr = strObjName.Split('@');
                                        if (arr.Length != 3)
                                            throw new Exception("что-то не так");
                                        arr[2] = Path.GetFileNameWithoutExtension(arr[2]) + last3 + Path.GetExtension(arr[2]);
                                        strObjName = string.Format("{0}@{1}@{2}", arr[0], arr[1], arr[2]);
                                    }
                                    if (_mSwAddin.GetObjectValue(_swSelModel, strObjName, (int)rd["type"],
                                                                 out strObjVal))
                                    {
                                        int val = GetCorrectIntValue(strObjVal);

                                        int number = isNumber ? (int)rd["number"] : (int)rd["id"];
                                        while (number != k && _dimensionConfig.Count != 0)
                                        {
                                            listForDimensions.AddRange(
                                                from dimensionConfiguration in _dimensionConfig
                                                where dimensionConfiguration.Number == k
                                                select
                                                    new DimensionConfForList(dimensionConfiguration.Number,
                                                                             dimensionConfiguration.Caption,
                                                                             "", -1,
                                                                             GetListIntFromString(
                                                                                 dimensionConfiguration.
                                                                                     IdSlave),
                                                                             dimensionConfiguration.
                                                                                 Component,
                                                                             false,
                                                                             dimensionConfiguration.Id));
                                            //Logging.Log.Instance.Debug("listForDimensions1:" + listForDimensions.Count.ToString());
开发者ID:digger1985,项目名称:MyCode,代码行数:67,代码来源:frmSetParameters.cs

示例6: getPriceForComponent

        private void getPriceForComponent(ModelDoc2 model, bool ParentCalcStruct, Action<decimal> nextPrice, Action<Exception, string> nextError)
        {
            string currentConfig = model.IGetActiveConfiguration().Name;

            if (currentConfig.ToLower().Contains("по умолчани") || currentConfig.ToLower().Contains("default"))
                currentConfig = string.Empty;

            string isProduct = model.GetCustomInfoValue(currentConfig, "IsProduct");
            if (string.IsNullOrEmpty(isProduct))
            {
                isProduct = model.GetCustomInfoValue(string.Empty, "IsProduct");
                if (string.IsNullOrEmpty(isProduct))
                    isProduct = "No";
            }

            if (isProduct == "Yes")
            {
                //изделие

                //Проверка существования артикула для компонента в случает отсутствия, расчет цены на сам компонент не производится
                string articul = model.GetCustomInfoValue(string.Empty, "Articul");
                if (string.IsNullOrEmpty(articul))
                    articul = model.GetCustomInfoValue(currentConfig, "Articul");

                if (!string.IsNullOrEmpty(articul))
                {
                    try
                    {
                        nextPrice(сalculatePriceForModel(model));
                    }
                    catch (Exception e)
                    {
                        if (checkError(e))
                            nextError(e, Path.GetFileName(model.GetPathName()));
                    }
                }

                string s = model.GetPathName();
                AssemblyDoc model_assembly = model as AssemblyDoc;
                if (model_assembly != null)
                {
                    bool calcStruct = true;
                    if (!string.IsNullOrEmpty(articul))
                    {
                        string calcStructStr = model.get_CustomInfo2(string.Empty, "CalcStruct");
                        if (calcStructStr.ToLower() == "no")
                            calcStruct = false;
                    }

                    var components = (object[])((AssemblyDoc)model).GetComponents(true);
                    foreach (var component in components)
                    {
                        var comp = (Component2)component;
                        ModelDoc2 _model = comp.IGetModelDoc();
                        if (_model != null)
                        {
                            getPriceForComponent(_model, calcStruct, nextPrice, nextError);
                        }
                    }
                }
            }
            else
            {
                //не изделие

                string articul = model.GetCustomInfoValue(string.Empty, "Articul");
                if (string.IsNullOrEmpty(articul))
                    articul = model.GetCustomInfoValue(currentConfig, "Articul");

                string isIndependentStr = model.get_CustomInfo2(string.Empty, "IsIndependent");
                bool isIndependent = true;
                if (string.IsNullOrEmpty(isIndependentStr) || isIndependentStr.ToLower() == "no")
                    isIndependent = false;

                if (isIndependent)
                {
                    bool calcStruct = true;
                    if (!string.IsNullOrEmpty(articul))
                    {
                        //независимый и с артикулом
                        try
                        {
                            nextPrice(сalculatePriceForModel(model));
                        }
                        catch (Exception e)
                        {
                            if (checkError(e))
                                nextError(e, Path.GetFileName(model.GetPathName()));
                        }
                        string calcStructStr = model.get_CustomInfo2(string.Empty, "CalcStruct");

                        if (calcStructStr.ToLower() == "no")
                            calcStruct = false;
                    }

                    if (calcStruct)
                    {
                        AssemblyDoc model_assembly = model as AssemblyDoc;
                        if (model_assembly != null)
                        {
//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:Repository.cs

示例7: Actualization

        public static void Actualization(ModelDoc2 model, SwAddin _mSwAddin)
        {
            Component2 _swSelectedComponent = model.ConfigurationManager.ActiveConfiguration.GetRootComponent3(true);
            OleDbCommand cm;
            OleDbDataReader rd;
            OleDbConnection oleDb;
            if (!_mSwAddin.OpenModelDatabase(model, out oleDb))
                return;
            cm = new OleDbCommand("SELECT * FROM faners ORDER BY FanerName ", oleDb);
            rd = cm.ExecuteReader();
            List<Faner> faners = new List<Faner>();
            while (rd.Read())
            {
                if (rd["FanerType"] as string != null)
                {
                    faners.Add(new Faner((string)rd["FanerName"], (string)rd["FanerType"], (string)rd["DecorGroup"]));
                }
                else
                {
                    faners.Add(new Faner((string)rd["FanerName"], string.Empty, (string)rd["DecorGroup"]));
                }
            }
            rd.Close();
            Feature feature;
            foreach (var faner in faners)
            {
                string suffix = faner.FanerName.Substring(faner.FanerName.Length - 2, 2);

                feature = FindEdge(_swSelectedComponent, faner.AxFanerName);
                if (feature != null)
                {
                    if (feature.IsSuppressed())
                    {
                        _mSwAddin.SetModelProperty(model, "Faner" + suffix, "", swCustomInfoType_e.swCustomInfoText, string.Empty, true);
                        _mSwAddin.SetModelProperty(model, "colorFaner" + suffix, "", swCustomInfoType_e.swCustomInfoText, string.Empty, true);
                    }
                    else
                    {
                        string fieldValue = model.GetCustomInfoValue(string.Empty, "Faner" + suffix);
                        if (fieldValue == string.Empty)
                        {
                            string msgText = "Для данной детали: " + model.GetPathName() + " кромка Faner" + suffix + " в модели не соответствует свойствам файла сборки. Данная кромка не будет импортирована в программу Покупки! Чтобы исправить эту ошибку используйте опцию \"MrDoors - Отделка кромки\"";
                            MessageBox.Show(msgText, @"MrDoors", MessageBoxButtons.OK);
                        }
                    }
                }
            }
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:48,代码来源:frmEdge.cs

示例8: GetCurrentAsmModel

 private ModelDoc2 GetCurrentAsmModel(ModelDoc2 swModel)
 {
     ModelDoc2 swAsmModel = null;
     LinkedList<ModelDoc2> outModels;
     if (_swAdd.GetAllUniqueModels(_swAdd.RootModel, out outModels))
     {
         SwDmDocumentOpenError oe;
         SwDMApplication swDocMgr = SwAddin.GetSwDmApp();
         var swDoc = (SwDMDocument8)swDocMgr.GetDocument(swModel.GetPathName(),
                                                          SwDmDocumentType.swDmDocumentDrawing, true, out oe);
         if (swDoc != null)
         {
             SwDMSearchOption src = swDocMgr.GetSearchOptionObject();
             object brokenRefVar;
             var varRef = (object[])swDoc.GetAllExternalReferences2(src, out brokenRefVar);
             var name = (string)varRef[0];
             swAsmModel = outModels.FirstOrDefault(modelDoc2 => modelDoc2.GetPathName().ToLower() == name.ToLower());
             swDoc.CloseDoc();
         }
     }
     return swAsmModel;
 }
开发者ID:digger1985,项目名称:MyCode,代码行数:22,代码来源:DimensionDraft.cs

示例9: GetRootFolder

 private static string GetRootFolder(ModelDoc2 inRootModel)
 {
     return Path.GetDirectoryName(inRootModel.GetPathName());
 }
开发者ID:digger1985,项目名称:MyCode,代码行数:4,代码来源:SwAddin.cs

示例10: SetObjectValue


//.........这里部分代码省略.........
                                    ModelDoc2 outModel;

                                    if (GetModelByName(inModel, inName, false, out outModel, true))
                                    {
                                        if (k == (int)swComponentSuppressionState_e.swComponentSuppressed)
                                        {
                                            //������� �������
                                            RenameCustomProperty(outModel, string.Empty, "Articul", "Noarticul");
                                        }
                                        else if (k == (int)swComponentSuppressionState_e.swComponentFullyResolved)
                                        {
                                            //����� �������
                                            RenameCustomProperty(outModel, string.Empty, "Noarticul", "Articul");
                                        }
                                    }
                                }
                                if (k == (int)swComponentSuppressionState_e.swComponentSuppressed)
                                    tmp = swComp.SetSuppression2(k);
                                k = tmp;

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

                                var equMrg = inModel.GetEquationMgr();
                                if (equMrg != null)
                                {
                                    var outList = new LinkedList<Component2>();
                                    if (GetComponents(inModel.IGetActiveConfiguration().IGetRootComponent2(), outList,
                                                      true,
                                                      false))
                                    {
                                        bool notSuppComp =
                                            outList.All(
                                                component2 =>
                                                !swComp.IsSuppressed() ||
                                                swComp.GetPathName() != component2.GetPathName() ||
                                                component2.IsSuppressed());
                                        for (int i = 0; i < inModel.GetEquationMgr().GetCount(); i++)
                                        {
                                            if (equMrg.Equation[i].Contains(
                                                Path.GetFileNameWithoutExtension(swComp.GetPathName())))
                                            {
                                                if ((equMrg.get_Suppression(i) ? 0 : 1) != inVal)
                                                {
                                                    equMrg.set_Suppression(i, inVal == 0 && notSuppComp);
                                                }
                                            }
                                        }
                                    }
                                }

                                #endregion

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

                                if (isCavity)
                                {
                                    LinkedList<Component2> swComps;
                                    List<Feature> list;
                                    if (_features.Count == 0 || _comps.Count == 0)
                                        list = GetAllCavitiesFeatures(out swComps);
                                    else
                                    {
                                        list = _features;
                                        swComps = _comps;
                                    }
                                    string nameMod = Path.GetFileNameWithoutExtension(inModel.GetPathName());

                                    var delList = (from component2 in swComps
                                                   where
                                                       component2.Name.Contains(nameMod) &&
                                                       component2.Name.Contains(swComp.Name)
                                                   from feature in list
                                                   where
                                                       component2.Name ==
                                                       GetSpecialNameFromFeature(feature.IGetFirstSubFeature().Name).
                                                           Split('/').First() + "/" +
                                                       GetSpecialNameFromFeature(feature.IGetFirstSubFeature().Name).
                                                           Split('/').ToArray()[1]
                                                   select feature).ToList();
                                    SwModel.ClearSelection();
                                    foreach (var feature in delList)
                                    {
                                        feature.Select(true);
                                    }
                                    SwModel.DeleteSelection(false);
                                }

                                #endregion

                                ret = (k == (int)swSuppressionError_e.swSuppressionChangeOk);
                            }
                        }
                        catch
                        {
                        }
                        break;
                }
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:SwAddin.cs

示例11: SetAsmUnit

        public bool SetAsmUnit(ModelDoc2 model, out LinkedList<Component2> swComps)
        {
            bool ret = false;
            Configuration swConfig;
            swComps = new LinkedList<Component2>();

            try
            {
                SetModelProperty(model, "AsmUnit", "", swCustomInfoType_e.swCustomInfoText, model.GetPathName());
                swConfig = (Configuration)model.GetActiveConfiguration();
                if (swConfig != null)
                {
                    var swRootComponent = (Component2)swConfig.GetRootComponent();
                    if (GetComponents(swRootComponent, swComps, true, false))
                    {
                        foreach (var component2 in swComps)
                        {
                            var mod = component2.IGetModelDoc();
                            if (mod != null)
                            {
                                bool isIndependent = (!string.IsNullOrEmpty(mod.GetCustomInfoValue("", "IsIndependent") as string) && mod.GetCustomInfoValue("", "IsIndependent") == "Yes");
                                if (isIndependent)
                                {
                                    SetModelProperty(mod, "AsmUnit", "", swCustomInfoType_e.swCustomInfoText, RootModel.GetPathName());
                                }
                                else
                                {
                                    var swParentComp = component2.GetParent();
                                    string val = swParentComp == null ? model.GetPathName() : swParentComp.GetPathName();
                                    SetModelProperty(mod, "AsmUnit", "", swCustomInfoType_e.swCustomInfoText, val);
                                }
                            }
                        }
                        ret = true;
                    }
                }
            }
            catch { }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:40,代码来源:SwAddin.cs

示例12: GetModelDatabaseFileName

        public string GetModelDatabaseFileName(ModelDoc2 inModel)
        {
            string ret = "";
            string strDbName = inModel.GetPathName();

            if (strDbName != "")
            {
                if (strDbName.Contains("_SWLIB_BACKUP")) // ���� ����� �� ����, �� �� ��������� ��������� 3 ������� ����� �����������
                {
                    string fileName = Path.GetFileNameWithoutExtension(strDbName);
                    fileName = string.Format("{0}{1}", fileName.Substring(0, fileName.Length - 4), Path.GetExtension(strDbName));
                    strDbName = Path.Combine(Path.GetDirectoryName(strDbName), fileName);
                }
                strDbName = GetModelNameWithoutSuffix(strDbName);
                if (Path.GetExtension(strDbName).ToLower() == ".slddrw")
                    strDbName = Path.GetFileNameWithoutExtension(strDbName) + ".sldasm";

                string DBPathResult = Furniture.Helpers.SaveLoadSettings.ReadAppSettings("DBPath") == string.Empty ? Properties.Settings.Default.DBPath : Furniture.Helpers.SaveLoadSettings.ReadAppSettings("DBPath");

                var dir = new DirectoryInfo(DBPathResult);
                //var dir = new DirectoryInfo(Properties.Settings.Default.DBPath); // ������ �������

                foreach (FileInfo file in dir.GetFiles(Path.GetFileName(strDbName) + ".mdb", SearchOption.AllDirectories))
                {
                    strDbName = file.FullName;
                    ret = strDbName;
                    break;
                }
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:31,代码来源:SwAddin.cs

示例13: 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

示例14: WriteXmlFile

        private string WriteXmlFile(ModelDoc2 swModel, bool isValidXml, string targetModelPath = null)
        {
            string ret = "";
            if (_createProgramm)
            {
                var path = Path.GetDirectoryName(_swAdd.RootModel.GetPathName());
                path = path + @"\Программы\";
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);

                string modelName = Path.GetFileName(swModel.GetPathName());

                ret = path + modelName + ".xml";

                string fnameWithoutExt = Path.GetFileNameWithoutExtension(swModel.GetPathName());
                fnameWithoutExt = fnameWithoutExt.Substring(fnameWithoutExt.Length - 4, 4);
                string underlyingModelFileName;
                if (fnameWithoutExt[0] == '#' && (fnameWithoutExt[3] == 'P' || fnameWithoutExt[3] == 'p'))
                {
                    underlyingModelFileName = targetModelPath;//@"D:\_SWLIB_BACKUP\ШКАФЫ-КУПЕ\Каркасные детали\ДСП 16 мм\8504F_Панель вкладная 000A#17P.SLDASM";
                }
                else
                    underlyingModelFileName = swModel.GetPathName().Replace("SLDDRW", "SLDASM");
                ModelDoc2 underlyingModel =(ModelDoc2) _swApp.OpenDoc(underlyingModelFileName, (int) swDocumentTypes_e.swDocASSEMBLY);

                string sketchNumber = underlyingModel.GetCustomInfoValue("", "Sketch Number");
                string orderNumber = underlyingModel.GetCustomInfoValue("", "Order Number");
                _swApp.CloseDoc(underlyingModelFileName);
                if (!(string.IsNullOrEmpty(sketchNumber) || string.IsNullOrEmpty(orderNumber)))
                    ret = Path.Combine(path, orderNumber + "_" + sketchNumber + ".xml");

                if (File.Exists(ret))
                {
                    File.Delete(ret);
                }
                try
                {
                    _cxml = new XmlDocument();
                    var element = _cxml.CreateElement("Model");
                    //modelName = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.UTF8.GetBytes(modelName)));
                    element.SetAttribute("Name", modelName);
                    element.SetAttribute("CNCValid", isValidXml.ToString());
                    element.SetAttribute("vAddInn", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    element.SetAttribute("vLib", Properties.Settings.Default.PatchVersion);
                    _node = _cxml.AppendChild(element);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"Ошибка: " + ex.Message);
                }
            }
            return ret;
        }
开发者ID:digger1985,项目名称:MyCode,代码行数:53,代码来源:DimensionDraft.cs

示例15: CopyDrawing

        private bool CopyDrawing(ModelDoc2 inModel, bool askIfExist, string whereToSearchDirectory)
        {
            bool ret = false;

            try
            {
                string strModelName = inModel.GetPathName();
                if (strModelName != "")
                {
                    string strDrwNewName; // ��� ���� ��������...
                    string strDrwName = string.Empty;
                    var dir = new DirectoryInfo(DrwPathResult);
                    if (strModelName.ToUpper().Contains("_SWLIB_BACKUP"))
                    {
                        strDrwNewName = Path.GetDirectoryName(RootModel.GetPathName()) + "\\�������\\" + Path.GetFileNameWithoutExtension(strModelName) + ".SLDDRW";

                        string modelNameWithoutExtension = Path.GetFileNameWithoutExtension(strModelName);
                        strDrwName = modelNameWithoutExtension.Substring(0, modelNameWithoutExtension.Length - 4);
                        foreach (FileInfo file in dir.GetFiles(strDrwName + ".SLDDRW", SearchOption.AllDirectories))
                        {
                            strDrwName = file.FullName;
                            break;
                        }
                        if (!Directory.Exists(Path.GetDirectoryName(RootModel.GetPathName()) + "\\�������"))
                            Directory.CreateDirectory(Path.GetDirectoryName(RootModel.GetPathName()) + "\\�������");
                    }
                    else
                    {
                        strDrwNewName = Path.GetDirectoryName(strModelName) + "\\" +
                                        Path.GetFileNameWithoutExtension(strModelName) + ".SLDDRW";
                        //string strDrwNewMyName = GetRootFolder(inRootModel) + "\\������� " + GetOrderName(inRootModel) + "\\" + Path.GetFileName(strDrwNewName);
                        strDrwName = GetModelNameWithoutSuffix(strModelName);
                        if (!string.IsNullOrEmpty(whereToSearchDirectory))
                        {
                            string[] postfixArr = Path.GetFileNameWithoutExtension(strModelName).Split('-');
                            string postfix = string.Empty;
                            if (postfixArr.Length > 1)
                                postfix = "*" + postfixArr.Last() + ".SLDDRW";
                            else
                                postfix = "*.SLDDRW";
                            dir = new DirectoryInfo(whereToSearchDirectory);
                            foreach (
                                FileInfo file in
                                    dir.GetFiles(Path.GetFileNameWithoutExtension(strDrwName) + postfix,
                                                 SearchOption.AllDirectories))
                            {
                                strDrwName = file.FullName;
                                break;
                            }
                        }
                        else
                        {
                            foreach (
                                FileInfo file in
                                    dir.GetFiles(Path.GetFileNameWithoutExtension(strDrwName) + ".SLDDRW",
                                                 SearchOption.AllDirectories))
                            {
                                strDrwName = file.FullName;
                                break;
                            }
                        }
                        if (!File.Exists(strDrwName) && !string.IsNullOrEmpty(whereToSearchDirectory))
                        {
                            // �������� �� ����������
                            strDrwName = GetModelNameWithoutSuffix(strModelName);
                            dir = new DirectoryInfo(DrwPathResult);
                            foreach (
                                FileInfo file in
                                    dir.GetFiles(Path.GetFileNameWithoutExtension(strDrwName) + ".SLDDRW",
                                                 SearchOption.AllDirectories))
                            {
                                strDrwName = file.FullName;
                                break;
                            }
                        }
                    }
                    if (File.Exists(strDrwName))
                    {
                        bool isOverwriteExistingFile = true;

                        if (File.Exists(strDrwNewName))
                        {
                            if (askIfExist)
                                isOverwriteExistingFile = (MessageBox.Show(@"���� " + strDrwNewName + @" ����������. �� ������ ������������ ���?",
                                    MyTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                            else
                                isOverwriteExistingFile = false;

                        }
                        if (isOverwriteExistingFile)
                        {
                            File.Copy(strDrwName, strDrwNewName, true);
                            File.SetAttributes(strDrwNewName, FileAttributes.Normal);

                            SwDmDocumentOpenError oe;
                            object brokenRefVar;

                            SwDMApplication swDocMgr = GetSwDmApp();
                            var swDoc = (SwDMDocument8)swDocMgr.GetDocument(strDrwNewName,
                                SwDmDocumentType.swDmDocumentDrawing, false, out oe);
//.........这里部分代码省略.........
开发者ID:digger1985,项目名称:MyCode,代码行数:101,代码来源:SwAddin.cs


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