示例#1
0
        private void ReadCustInfo()
        {
            string val    = "";
            string valOut = "";
            bool   retVal;

            retVal            = SwCustPropMgr.Get4("图样代号", false, out val, out valOut);
            TextBoxDwgNo.Text = valOut.Trim();
            _swInfo.DwgNo     = valOut.Trim();

            retVal = SwCustPropMgr.Get4("图样名称", false, out val, out valOut);
            TextBoxDwgName.Text = valOut.Trim();
            _swInfo.DwgName     = valOut.Trim();

            retVal           = SwCustPropMgr.Get4("备注", false, out val, out valOut);
            TextBoxNote.Text = valOut.Trim();
            _swInfo.Note     = valOut.Trim();
        }
示例#2
0
                static string GetProperty(CustomPropertyManager propManger, string propName)
                {
                    string valOut;
                    string value;

                    propManger.Get4(propName, true, out valOut, out value);

                    if (string.IsNullOrEmpty(value))
                    {
                        return(null);
                    }
                    else
                    {
                        return(value);
                    }
                }
示例#3
0
        protected int _getNameFromFile()
        {
            ModelDoc2 swDoc;
            int       errors = 0;

            swDoc = (ModelDoc2)swApp.OpenDocSilent(Path.Combine(project.workDir, file), (int)docType, ref errors);
            CustomPropertyManager swCustProp = swDoc.Extension.get_CustomPropertyManager("");
            string o, ro;

            swCustProp.Get4(Settings.Default.propertyName, false, out o, out ro);
            name                = ro;
            updatePending       = false;
            swApp.OnIdleNotify -= new DSldWorksEvents_OnIdleNotifyEventHandler(_getNameFromFile);
            updateDBForm();
            return(0);
        }
        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);
        }