Пример #1
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");
            }
        }
Пример #2
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();
                    }
                }
            }
        }
Пример #3
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");
            }
        }