Ejemplo n.º 1
0
        private String GetRev(ModelDocExtension swModExt)
        {
            swCustPropMgr = (CustomPropertyManager)swModExt.get_CustomPropertyManager("");
            String[] propNames      = (String[])swCustPropMgr.GetNames();
            String   ValOut         = String.Empty;
            String   ResolvedValOut = String.Empty;
            Boolean  WasResolved    = false;

            String result = String.Empty;

            foreach (String name in propNames)
            {
                swCustPropMgr.Get5(name, false, out ValOut, out ResolvedValOut, out WasResolved);
                if (name.Contains("REVISION") && !name.Contains(@"LEVEL") && ValOut != String.Empty)
                {
                    result = "-" + ValOut;
                }
            }

            if (result.Length != 3)
            {
                MustHaveRevException e = new MustHaveRevException("Check to make sure drawing is at least revision AA or later.");
                //e.Data.Add("who", System.Environment.UserName);
                //e.Data.Add("when", DateTime.Now);
                //e.Data.Add("result", result);
                throw e;
            }

            //System.Diagnostics.Debug.Print(result);
            return(result);
        }
Ejemplo n.º 2
0
        private SwProperty AssignProperty(CustomPropertyManager pm, string name)
        {
            int    res;
            int    success   = (int)swCustomInfoGetResult_e.swCustomInfoGetResult_ResolvedValue;
            bool   useCached = false;
            string valOut    = string.Empty;
            string resValOut = string.Empty;
            bool   wasResolved;

            SwProperty rp = new SwProperty();

            rp.SwApp = this.SwApp;

            if (!InThere(pm, name))
            {
                return(rp);
            }
            else
            {
            }

            res = pm.Get5(name, useCached, out valOut, out resValOut, out wasResolved);

            if (res == success)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Found {0}.", name));
                rp.Name     = name;
                rp.Value    = valOut;
                rp.ResValue = resValOut;
                rp.Type     = swCustomInfoType_e.swCustomInfoText;
                rp.Global   = true;
            }
            return(rp);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Pull the description string from a part/assembly in a View.
        /// </summary>
        /// <param name="v">A View object.</param>
        /// <returns>A description string.</returns>
        public static string get_description(SolidWorks.Interop.sldworks.View v)
        {
            ModelDoc2            md    = (ModelDoc2)v.ReferencedDocument;
            ConfigurationManager cfMgr = md.ConfigurationManager;
            Configuration        cf    = cfMgr.ActiveConfiguration;

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

            string _value    = "PART";
            string _resValue = string.Empty;
            bool   wasResolved;
            bool   useCached = false;

            if (cf != null)
            {
                scpm = cf.CustomPropertyManager;
            }
            else
            {
                scpm = gcpm;
            }
            int res;

            res = gcpm.Get5("Description", useCached, out _value, out _resValue, out wasResolved);
            if (_value == string.Empty)
            {
                res = scpm.Get5("Description", useCached, out _value, out _resValue, out wasResolved);
            }
            return(_value);
        }
Ejemplo n.º 4
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);
        }
        public static void ReadCusp(ModelDoc2 Doc)
        {
            StringBuilder         Sb     = new StringBuilder("");
            CustomPropertyManager SwCusp = Doc.Extension.CustomPropertyManager[""];
            string outv      = "";
            string outr      = "";
            bool   outresult = false;

            SwCusp.Get5("零件名", true, out outv, out outr, out outresult);
            Sb.Append("[零件名]:\r\n表达式:" + outv + "\r\n评估值:" + outr);
            Sb.Append("\r\n");
            SwCusp.Get5("代号", true, out outv, out outr, out outresult);
            Sb.Append("[代号]:\r\n表达式:" + outv + "\r\n评估值:" + outr);
            Sb.Append("\r\n");
            SwCusp.Get5("材料", true, out outv, out outr, out outresult);
            Sb.Append("[材料]:\r\n表达式:" + outv + "\r\n评估值:" + outr);
            System.Windows.MessageBox.Show(Sb.ToString().Trim());
        }
Ejemplo n.º 6
0
        public bool IsMetal(View v)
        {
            ModelDoc2            md    = (ModelDoc2)v.ReferencedDocument;
            ConfigurationManager cfMgr = md.ConfigurationManager;
            Configuration        cf    = cfMgr.ActiveConfiguration;

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

            string _value    = "WOOD";
            string _resValue = string.Empty;
            bool   wasResolved;
            bool   useCached = false;

            if (cf != null)
            {
                scpm = cf.CustomPropertyManager;
            }
            else
            {
                scpm = gcpm;
            }
            int res;

            res = gcpm.Get5("DEPARTMENT", useCached, out _value, out _resValue, out wasResolved);
            if (_value == string.Empty)
            {
                res = gcpm.Get5("DEPTID", useCached, out _value, out _resValue, out wasResolved);
                if (_value == string.Empty)
                {
                    res = scpm.Get5("DEPARTMENT", useCached, out _value, out _resValue, out wasResolved);
                }
            }

            if (_value == "2" || _value.ToUpper() == "METAL")
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Directly draws from SW.
        /// </summary>
        public void Get()
        {
            if (SwApp != null)
            {
                ModelDoc2            md    = (ModelDoc2)this.SwApp.ActiveDoc;
                ConfigurationManager cfMgr = md.ConfigurationManager;
                Configuration        cf    = cfMgr.ActiveConfiguration;

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

                bool wasResolved;
                bool useCached = false;

                if (cf != null)
                {
                    scpm = cf.CustomPropertyManager;
                }
                else
                {
                    scpm = gcpm;
                }

                if (SWCustPropMgr != null)
                {
                    scpm = SWCustPropMgr;
                }

                int res;

                if (this.Global)
                {
                    res       = gcpm.Get5(Name, useCached, out _value, out _resValue, out wasResolved);
                    this.Type = (swCustomInfoType_e)gcpm.GetType2(this.Name);


                    if (Type == swCustomInfoType_e.swCustomInfoNumber && Name.ToUpper().Contains("OVER"))
                    {
                        Type = swCustomInfoType_e.swCustomInfoDouble;
                    }
                }
                else
                {
                    res       = scpm.Get5(Name, useCached, out _value, out _resValue, out wasResolved);
                    this.Type = (swCustomInfoType_e)gcpm.GetType2(Name);
                }
            }
            else
            {
                throw new NullReferenceException("sw is null");
            }
        }
Ejemplo n.º 8
0
        private int SavePDFCopy(string fileName)
        {
            try
            {
                ModelDocExtension swModExt        = this.ModelDocument.Extension;
                ExportPdfData     swExportPDFData = (ExportPdfData)this.SolidworksApp.GetExportFileData((int)swExportDataFileType_e.swExportPdfData);
                bool     boolstatus = false;
                int      errors     = 0;
                int      warnings   = 0;
                string[] obj        = null;

                string description;
                string resolvedDescription;
                bool   wasResolved;
                string revision;
                string resolverdRevision;
                CustomPropertyManager swCustProp = swModExt.CustomPropertyManager[string.Empty];

                swCustProp.Get5("Description", false, out description, out resolvedDescription, out wasResolved);
                swCustProp.Get5("Revision", false, out revision, out resolverdRevision, out wasResolved);


                string pdffilename = fileName.ToUpper().Replace(".SLDDRW", string.Empty);

                string previousNames = pdffilename.Substring(pdffilename.LastIndexOf('\\') + 1);
                pdffilename = pdffilename.Substring(pdffilename.LastIndexOf('\\'));


                if (this.UserAddin.AppendRevision)
                {
                    pdffilename += ", Rev. " + revision;
                }

                if (this.UserAddin.AppendDescription)
                {
                    pdffilename += ", " + description;
                }

                string useDirectory;
                // find project sub-directory
                var subDir = new DirectoryInfo(this.UserAddin.PDFLocation + "\\" + previousNames.Substring(0, 2));
                if (subDir.Exists)
                {
                    useDirectory = this.UserAddin.PDFLocation + "\\" + previousNames.Substring(0, 2);
                }
                else
                {
                    useDirectory = this.UserAddin.PDFLocation;
                }

                //Delete the old versions
                if (this.UserAddin.RemovePrevious)
                {
                    var dir = new DirectoryInfo(useDirectory);

                    foreach (var file in dir.EnumerateFiles(previousNames + "*.pdf"))
                    {
                        file.Delete();
                    }
                }

                pdffilename = useDirectory + pdffilename + ".pdf";

                obj = this.doc.GetSheetNames();
                int count = 0;
                count = obj.Length;
                int               i        = 0;
                object[]          objs     = new object[count - 1];
                DispatchWrapper[] arrObjIn = new DispatchWrapper[count - 1];

                // Activate each drawing sheet, except the last drawing sheet, for
                // demonstration purposes only and add each sheet to an array
                // of drawing sheets
                for (i = 0; i < count - 1; i++)
                {
                    boolstatus = this.doc.ActivateSheet(obj[i]);
                    Sheet swSheet = (Sheet)this.doc.GetCurrentSheet();
                    objs[i]     = swSheet;
                    arrObjIn[i] = new DispatchWrapper(objs[i]);
                }

                // Save the drawings sheets to a PDF file
                swExportPDFData.SetSheets((int)swExportDataSheetsToExport_e.swExportData_ExportAllSheets, arrObjIn);
                swExportPDFData.ViewPdfAfterSaving = this.UserAddin.ShowPDF;

                swModExt.SaveAs(pdffilename, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, swExportPDFData, ref errors, ref warnings);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Problem Saving the PDF. " + e.Message);
            }

            return(0);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Directly draws from SW, assinging SwApp. Why do I have all these?
        /// </summary>
        /// <param name="md">A ModelDoc2.</param>
        /// <param name="cd">The Cutlist handler.</param>
        public void Get2(ModelDoc2 md, CutlistData cd)
        {
            Configuration cf = md.ConfigurationManager.ActiveConfiguration;

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

            bool   wasResolved;
            bool   useCached  = false;
            string tempval    = string.Empty;
            string tempresval = string.Empty;

            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.Get5(Name, useCached, out tempval, out tempresval, out wasResolved);
                if (res == (int)swCustomInfoGetResult_e.swCustomInfoGetResult_NotPresent)
                {
                    Value    = tempval;
                    ResValue = tempresval;
                    Type     = (swCustomInfoType_e)gcpm.GetType2(this.Name);
                }
                else // check in wrong place; sometimes it's there.
                {
                    res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved);
                    if (wasResolved)
                    {
                        Value    = tempval;
                        ResValue = tempresval;
                        Type     = (swCustomInfoType_e)gcpm.GetType2(this.Name);
                    }
                }

                if (Type == swCustomInfoType_e.swCustomInfoNumber && Name.ToUpper().Contains("OVER"))
                {
                    Type = swCustomInfoType_e.swCustomInfoDouble;
                }

                if (this.Name.Contains("OP"))
                {
                    int tp = 0;

                    if (int.TryParse(this._value, out tp))
                    {
                        ID     = _resValue;
                        _descr = cd.GetOpAbbreviationByID(_resValue);
                    }
                    else
                    {
                        ID = cd.GetOpIDByName(_resValue).ToString();
                    }
                }
            }
            else
            {
                res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved);
                if (wasResolved)
                {
                    Value    = tempval;
                    ResValue = tempresval;
                    Type     = (swCustomInfoType_e)scpm.GetType2(this.Name);
                }
                if (Name.ToUpper().Contains("CUTLIST MATERIAL"))
                {
                    int tp = 0;
                    if (int.TryParse(_value, out tp))
                    {
                        ID     = _resValue;
                        _value = cd.GetMaterialByID(_resValue);
                    }
                    else
                    {
                        ID = cd.GetMaterialID(_value).ToString();
                    }
                }

                if (Name.ToUpper().Contains("EDGE"))
                {
                    int tp = 0;
                    if (int.TryParse(_value, out tp))
                    {
                        ID     = _resValue;
                        _value = cd.GetEdgeByID(_resValue);
                    }
                    else
                    {
                        ID = cd.GetEdgeID(_value).ToString();
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Directly draws from SW, assinging SwApp. Why do I have all these?
        /// </summary>
        /// <param name="md">A ModelDoc2.</param>
        /// <param name="cd">The Cutlist handler.</param>
        public virtual void Get(ModelDoc2 md, CutlistData cd)
        {
            Configuration cf = md.ConfigurationManager.ActiveConfiguration;

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

            bool   wasResolved;
            bool   useCached  = false;
            string tempval    = string.Empty;
            string tempresval = string.Empty;

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

            if (SWCustPropMgr != null)
            {
                scpm = SWCustPropMgr;
            }

            int res;

            res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved);

            if (res == (int)swCustomInfoGetResult_e.swCustomInfoGetResult_NotPresent ||
                tempval == string.Empty)
            {
                res = gcpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved);
                if (tempval != string.Empty)
                {
                    Value    = tempval;
                    ResValue = tempresval;
                }
            }
            else
            {
                Value    = tempval;
                ResValue = tempresval;
            }

            if (Name.ToUpper().Contains("CUTLIST MATERIAL") || Name.ToUpper().Contains("CLID"))
            {
                int tp = 0;
                if (int.TryParse(Value, out tp))
                {
                    ID    = Value;
                    Descr = cd.GetMaterialByID(Value);
                    Value = ID;
                }
                else
                {
                    ID    = cd.GetMaterialID(Value).ToString();
                    Descr = Value;
                }
            }

            if (Name.Contains("OP"))
            {
                int tp = 0;
                if (int.TryParse(Value, out tp))
                {
                    ID    = Value;
                    Descr = cd.GetOpAbbreviationByID(Value);
                }
                else
                {
                    ID    = cd.GetOpIDByName(Value).ToString();
                    Descr = Value;
                }
            }

            if (Name.ToUpper().Contains("EDGE") || (Name.ToUpper().StartsWith("E") && Name.ToUpper().EndsWith("ID")))
            {
                int tp = 0;
                if (int.TryParse(Value, out tp))
                {
                    ID    = Value;
                    Descr = cd.GetEdgeByID(Value);
                }
                else
                {
                    ID    = cd.GetEdgeID(Value).ToString();
                    Descr = Value;
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Directly draws from SW, assinging SwApp.
        /// </summary>
        /// <param name="sw">SwApp</param>
        public void Get(SldWorks sw)
        {
            if (sw != null)
            {
                this.SwApp = sw;
                ModelDoc2     md = (ModelDoc2)sw.ActiveDoc;
                Configuration cf = md.ConfigurationManager.ActiveConfiguration;

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

                bool   wasResolved;
                bool   useCached  = false;
                string tempval    = string.Empty;
                string tempresval = string.Empty;

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

                if (SWCustPropMgr != null)
                {
                    scpm = SWCustPropMgr;
                }

                int res;

                if (this.Global)
                {
                    res = gcpm.Get5(this.Name, useCached, out tempval, out tempresval, out wasResolved);
                    if (wasResolved)
                    {
                        Value    = tempval;
                        ResValue = tempresval;
                        Type     = (swCustomInfoType_e)gcpm.GetType2(this.Name);
                    }

                    if (Type == swCustomInfoType_e.swCustomInfoNumber && Name.ToUpper().Contains("OVER"))
                    {
                        Type = swCustomInfoType_e.swCustomInfoDouble;
                    }
                }
                else
                {
                    res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved);
                    if (wasResolved)
                    {
                        Value    = tempval;
                        ResValue = tempresval;
                        Type     = (swCustomInfoType_e)scpm.GetType2(this.Name);
                    }
                }
            }
            else
            {
                throw new NullReferenceException("sw is null");
            }
        }
Ejemplo n.º 12
0
        public void Read()
        {
            ModelDoc2             md = (ModelDoc2)this._swApp.ActiveDoc;
            CustomPropertyManager pm = md.Extension.get_CustomPropertyManager(string.Empty);
            int    success           = (int)swCustomInfoGetResult_e.swCustomInfoGetResult_ResolvedValue;
            int    res;
            bool   useCached = false;
            string valOut    = string.Empty;
            string resValOut = string.Empty;
            bool   wasResolved;


            res = pm.Get5("PartNo", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("PartNo", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
                this.GetProperty("PartNo").ResValue = resValOut;
            }

            res = pm.Get5("CUSTOMER", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("CUSTOMER", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("REVISION LEVEL", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("REVISION LEVEL", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("DrawnBy", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("DrawnBy", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("DATE", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("DATE", swCustomInfoType_e.swCustomInfoDate, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("M1", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("M1", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }
            res = pm.Get5("FINISH 1", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("FINISH 1", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("M2", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("M2", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }
            res = pm.Get5("FINISH 2", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("FINISH 2", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("M3", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("M3", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }
            res = pm.Get5("FINISH 3", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("FINISH 3", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("M4", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("M4", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }
            res = pm.Get5("FINISH 4", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("FINISH 4", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }

            res = pm.Get5("M5", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("M5", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }
            res = pm.Get5("FINISH 5", useCached, out valOut, out resValOut, out wasResolved);
            if (res == success)
            {
                SwProperty x = new SwProperty("FINISH 5", swCustomInfoType_e.swCustomInfoText, valOut, true);
                x.SwApp = this._swApp;
                this._innerArray.Add(x);
            }
        }
Ejemplo n.º 13
0
        public static void GetProperties(string ConfigName)
        {
            string ValOut;
            string ResValOut;
            bool   WasResolved;

            cust  = swModel.Extension.CustomPropertyManager[""];
            cust2 = swModel.Extension.CustomPropertyManager[ConfigName];


            if (docType != swDocumentTypes_e.swDocDRAWING)
            {
                cust.Get5("Код документа", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.DocCode = ResValOut;
                cust.Get5("Тип документа", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.DocType = ResValOut;
                cust.Get5("Конструктор", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.DevelopedBy = ResValOut;
                cust.Get5("Проверил", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.ChechedBy = ResValOut;
                cust.Get5("Техконтроль", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.TControl = ResValOut;
                cust.Get5("Нормоконтроль", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.NControl = ResValOut;
                cust.Get5("Нач.отд.", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.NachOtd = ResValOut;
                cust.Get5("Утвердил", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.ApprovedBy = ResValOut;
                cust.Get5("Контора", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Subvision = ResValOut;
                cust.Get5("Изменение", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Changing = ResValOut;
                cust.Get5("N извещения", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Notification = ResValOut;
                cust.Get5("MassaFormat", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.MassaFormat = ResValOut;
            }
            else
            {
                // Drawing
                cust.Get5("Литера", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Letter2 = ResValOut;
                cust.Get5("Материал", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Material = ResValOut;
                cust.Get5("Тип документа1", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.DocType1 = ResValOut;
                cust.Get5("Литера2", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Letter2 = ResValOut;
                cust.Get5("Литера3", false, out ValOut, out ResValOut, out WasResolved);
                Propertiy.Letter3 = ResValOut;
            }

            cust2.Get5("Исполнение", false, out ValOut, out ResValOut, out WasResolved);
            Propertiy._Version = (ResValOut == String.Empty) ? "0" : ResValOut;
            cust2.Get5("Обозначение", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.Designition = ResValOut;
            cust2.Get5("Раздел", false, out ValOut, out ResValOut, out WasResolved);
            Propertiy.Division = ResValOut;
            cust2.Get5("Масса", false, out ValOut, out ResValOut, out WasResolved);
            Propertiy.Weight = ResValOut;
            cust2.Get5("Наименование", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.Name = ResValOut;
            cust2.Get5("PDMflag", true, out ValOut, out ResValOut, out WasResolved);
            Propertiy.PDMflag = ResValOut;

            AddPropertiesFromModel();
        }
        public DataRow GetCustomProp(string configName, bool withImage = false, bool merge = false)
        {
            DataRow dr = propScaffold.MainRow;

            // Return an empty DataRow if the config name doesn't exist in this model
            if (configName != "" && !configNames.Contains(configName))
            {
                return(dr);
            }

            // Get property manager for this config
            CustomPropertyManager swCustPropMgr    = (CustomPropertyManager)swModelDocExt.get_CustomPropertyManager(configName);
            CustomPropertyManager swAltCustPropMgr = (CustomPropertyManager)swModelDocExt.get_CustomPropertyManager("");

            string[]      nameArray = swCustPropMgr.GetNames();
            List <string> propNames = new List <string>();

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

            dr["filename"]      = pathName;
            dr["configname"]    = configName;
            dr["PlaceHoldFlag"] = false;
            dr["ShowChildren"]  = swMainConfig.ShowChildComponentsInBOM;

            // Get custom properties from specific configuration
            // Get the file level properties when the config name is an empty string (i.e. "")
            string strVal;
            string strResolved;

            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();
                swCustPropMgr.Get4(propName, false, out strVal, out strResolved);
                strResolved   = strResolved.Trim();
                dr[fieldName] = GetPropDefaultValue(strResolved, typeName);

                // If merging config specific properties with the file level properties
                if (merge && configName != "" && !propNames.Contains(propName))
                {
                    swAltCustPropMgr.Get4(propName, false, out strVal, out strResolved);
                    strResolved   = strResolved.Trim();
                    dr[fieldName] = GetPropDefaultValue(strResolved, typeName);
                }
            }

            // Get model image
            // The default is swIsometricView = 7
            // Only get an image if the part is measured in discreet (non-continuous) units
            propScaffold.UomMapping.TryGetValue(dr["Uom"].ToString(), out string matchedUom);
            if (withImage && matchedUom == "EA")
            {
                byte[] bytes       = PropertyScaffold.ImageToByteArray(GetIsometricImage());
                string imageString = Convert.ToBase64String(bytes);
                dr["Image"] = imageString;
            }

            // Get sheet metal properties
            if (swMainModel.GetType() == (int)swDocumentTypes_e.swDocPART && IsSheetMetal())
            {
                Feature cutList = GetUpdatedCutList();

                if (cutList != null)
                {
                    // Get sheet metal properties
                    //Feature cutList = swMainModel.SelectionManager.GetSelectedObject6(1, 0);
                    CustomPropertyManager cutPropMgr = cutList.CustomPropertyManager;
                    List <string>         names = new List <string>(cutPropMgr.GetNames());
                    string valOut; string resolvedValOut; decimal decimalValOut; int intValOut; bool wasResolved;
                    cutPropMgr.Get5("Sheet Metal Thickness", false, out valOut, out resolvedValOut, out wasResolved);
                    Decimal.TryParse(resolvedValOut, out decimal sheetThickness);
                    if (names.Contains("Sheet Metal Thickness") && sheetThickness != 0.0M)
                    {
                        cutPropMgr.Get5("Cutting Length-Outer", false, out valOut, out resolvedValOut, out wasResolved);
                        Decimal.TryParse(resolvedValOut, out decimalValOut);
                        dr["CuttingLengthOuter"] = Decimal.Round(decimalValOut, 2);

                        cutPropMgr.Get5("Cutting Length-Inner", false, out valOut, out resolvedValOut, out wasResolved);
                        Decimal.TryParse(resolvedValOut, out decimalValOut);
                        dr["CuttingLengthInner"] = Decimal.Round(decimalValOut, 2);

                        cutPropMgr.Get5("Cut Outs", false, out valOut, out resolvedValOut, out wasResolved);
                        int.TryParse(resolvedValOut, out intValOut);
                        dr["CutOutCount"] = intValOut;

                        cutPropMgr.Get5("Bends", false, out valOut, out resolvedValOut, out wasResolved);
                        int.TryParse(resolvedValOut, out intValOut);
                        dr["BendCount"] = intValOut;

                        Decimal mult = AZI_SWCustomProperties.Properties.AppSettings.Default.AreaFactor;
                        cutPropMgr.Get5("Bounding Box Length", false, out valOut, out resolvedValOut, out wasResolved);
                        Decimal.TryParse(resolvedValOut, out decimal boxLength);
                        cutPropMgr.Get5("Bounding Box Width", false, out valOut, out resolvedValOut, out wasResolved);
                        Decimal.TryParse(resolvedValOut, out decimal boxWidth);
                        Decimal qty = Math.Ceiling((boxLength + mult * sheetThickness) * (boxWidth + mult * sheetThickness));
                        dr["ChildQty"] = Decimal.Round(qty, 2);
                    }
                }
            }

            return(dr);
        }