Exemple #1
0
        /// <summary>
        /// Get a custom property from the sheet set
        /// </summary>
        /// <param name="sheetSet">The Sheet Set to search.</param>
        /// <param name="propertyName">The name to look for.</param>
        /// <returns>The Custom Property.</returns>
        public static CustomProperty ByName(SheetSet sheetSet, string propertyName)
        {
            CustomProperty          retVal    = null;
            AcSmCustomPropertyValue propValue = sheetSet.BaseObject.GetCustomPropertyBag().GetProperty(propertyName);

            retVal = new CustomProperty(propertyName, propValue.GetValue(), (int)propValue.GetFlags());
            return(retVal);
        }
        // Synchronize the properties of a sheet with the sheet set
        private void SyncProperties(AcSmDatabase sheetSetDatabase)
        {
            // Get the objects in the sheet set
            IAcSmEnumPersist enumerator = sheetSetDatabase.GetEnumerator();

            // Get the first object in the Enumerator
            IAcSmPersist item = enumerator.Next();

            // Step through all the objects in the sheet set
            while ((item != null))
            {
                IAcSmSheet sheet = null;

                // Check to see if the object is a sheet
                if (item.GetTypeName() == "AcSmSheet")
                {
                    sheet = (IAcSmSheet)item;

                    // Create a reference to the Property Enumerator for
                    // the Custom Property Bag
                    IAcSmEnumProperty enumeratorProperty = item.GetDatabase().GetSheetSet().GetCustomPropertyBag().GetPropertyEnumerator();

                    // Get the values from the Sheet Set to populate to the sheets
                    string name = "";
                    AcSmCustomPropertyValue customPropertyValue = null;

                    // Get the first property
                    enumeratorProperty.Next(out name, out customPropertyValue);

                    // Step through each of the properties
                    while ((customPropertyValue != null))
                    {
                        // Check to see if the property is for a sheet
                        if (customPropertyValue.GetFlags() == PropertyFlags.CUSTOM_SHEET_PROP)
                        {
                            //// Create a reference to the Custom Property Bag
                            //AcSmCustomPropertyBag customSheetPropertyBag = sheet.GetCustomPropertyBag();

                            //// Create a reference to a Custom Property Value
                            //AcSmCustomPropertyValue customSheetPropertyValue = new AcSmCustomPropertyValue();
                            //customSheetPropertyValue.InitNew(sheet);

                            //// Set the flag for the property
                            //customSheetPropertyValue.SetFlags(customPropertyValue.GetFlags());

                            //// Set the value for the property
                            //customSheetPropertyValue.SetValue(customPropertyValue.GetValue());

                            //// Create the property
                            //customSheetPropertyBag.SetProperty(name, customSheetPropertyValue);

                            SetCustomProperty(sheet, name, customPropertyValue.GetValue(), customPropertyValue.GetFlags());
                        }

                        // Get the next property
                        enumeratorProperty.Next(out name, out customPropertyValue);
                    }
                }

                // Get the next Sheet
                item = enumerator.Next();
            }
        }