Beispiel #1
0
        /// <summary>
        /// Gets the custom property.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="swModel">The SolidWorks model.</param>
        /// <param name="configuration">The configuration (the generic custom property will be used if no configuration specified).</param>
        /// <returns>The resolved property value, or null if the property is not found.</returns>
        public static string GetCustomProperty(string propertyName, IModelDoc2 swModel, string configuration = null)
        {
            // Obtain the custom property manager for the given configuration
            if (configuration == null)
            {
                configuration = string.Empty;
            }
            ICustomPropertyManager swCustomPropertyManager = swModel.Extension.CustomPropertyManager[configuration];

            if (swCustomPropertyManager == null)
            {
                Debug.Fail("Custom property manager is null, configuration " + configuration + " may not exist");
                return(null);
            }

            // Obtain the custom property based on its name
            string valOut;
            string resolvedValOut;
            bool   wasResolved;

            swCustomPropertyManager.Get5(propertyName, false, out valOut, out resolvedValOut, out wasResolved);

            // As the UseCache was set to false we will always receive a resolved value
            return(resolvedValOut);
        }
Beispiel #2
0
        protected override void SetProperty(ICustomPropertyManager prpMgr, string name, object value)
        {
            if (m_RefDoc.Configurations.Active.Configuration != m_RefConf.Configuration)
            {
                throw new ConfigurationSpecificCutListPropertiesWriteNotSupportedException();
            }

            base.SetProperty(prpMgr, name, value);
        }
        /// <summary>
        /// Stores the reference to the interop and gets all the property names
        /// </summary>
        /// <param name="propertyManager"></param>
        public SolidWorksCustomPropertyManager(ICustomPropertyManager propertyManager)
        {
            _propertyManager = propertyManager;

            var names = _propertyManager.GetNames();

            if (names == null)
            {
                return;
            }

            foreach (var n in names)
            {
                this.Add(n);
            }
        }
            internal PropertiesList(ICustomPropertyManager prpsMgr) : base(StringComparer.CurrentCultureIgnoreCase)
            {
                var prpNames = prpsMgr.GetNames() as string[];

                if (prpNames != null)
                {
                    foreach (var prpName in prpNames)
                    {
                        string val;
                        string resVal;
                        bool   wasRes;
                        prpsMgr.Get5(prpName, true, out val, out resVal, out wasRes);
                        Add(prpName, val);
                    }
                }
            }
Beispiel #5
0
        internal SwCustomPropertyEnumerator(IModelDoc2 model, ICustomPropertyManager prpMgr, string confName, CustomPropertiesEventsHelper evHelper)
        {
            m_Model    = model;
            m_PrpMgr   = prpMgr;
            m_ConfName = confName;

            m_EvHelper = evHelper;

            m_PrpNames = m_PrpMgr.GetNames() as string[];

            if (m_PrpNames == null)
            {
                m_PrpNames = new string[0];
            }

            m_CurPrpIndex = -1;
        }
Beispiel #6
0
        private string GetPropertyValue(ICustomPropertyManager prpMgr, string prpName)
        {
            string resVal;

            if (OwnerApplication.IsVersionNewerOrEqual(SwVersion_e.Sw2018))
            {
                prpMgr.Get6(prpName, false, out _, out resVal, out _, out _);
            }
            else if (OwnerApplication.IsVersionNewerOrEqual(SwVersion_e.Sw2014))
            {
                prpMgr.Get5(prpName, false, out _, out resVal, out _);
            }
            else
            {
                prpMgr.Get4(prpName, false, out _, out resVal);
            }

            return(resVal);
        }
            internal PropertiesList(ICustomPropertyManager prpsMgr, ISldWorks app) : base(StringComparer.CurrentCultureIgnoreCase)
            {
                var prpNames = prpsMgr.GetNames() as string[];

                if (prpNames != null)
                {
                    foreach (var prpName in prpNames)
                    {
                        string val;
                        string resVal;
                        if (app.IsVersionNewerOrEqual(SwVersion_e.Sw2014))
                        {
                            bool wasRes;
                            prpsMgr.Get5(prpName, true, out val, out resVal, out wasRes);
                        }
                        else
                        {
                            prpsMgr.Get4(prpName, true, out val, out resVal);
                        }
                        Add(prpName, val);
                    }
                }
            }
 public ICustomPropertyManagerObject(ICustomPropertyManager ICustomPropertyManagerinstance)
 {
     ICustomPropertyManagerInstance = ICustomPropertyManagerinstance;
 }