// Set/create a custom sheet or sheet set property
        private void SetCustomProperty(IAcSmPersist owner, string propertyName, object propertyValue, PropertyFlags sheetSetFlag)
        {
            // Create a reference to the Custom Property Bag
            AcSmCustomPropertyBag customPropertyBag = default(AcSmCustomPropertyBag);

            if (owner.GetTypeName() == "AcSmSheet")
            {
                AcSmSheet sheet = (AcSmSheet)owner;
                customPropertyBag = sheet.GetCustomPropertyBag();
            }
            else
            {
                AcSmSheetSet sheetSet = (AcSmSheetSet)owner;
                customPropertyBag = sheetSet.GetCustomPropertyBag();
            }

            // Create a reference to a Custom Property Value
            AcSmCustomPropertyValue customPropertyValue = new AcSmCustomPropertyValue();

            customPropertyValue.InitNew(owner);

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

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

            // Create the property
            customPropertyBag.SetProperty(propertyName, customPropertyValue);
        }
Exemple #2
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);
        }
        public static void AddCustomProperty(this AcSmCustomPropertyBag bag, IAcSmComponent comp,
                                             SSProp prop, SheetSet ss = null)
        {
            var customProp = new AcSmCustomPropertyValue();

            customProp.InitNew(comp);
            customProp.SetFlags(GetPropType(prop.Type));
            customProp.SetValue(prop.Value);
            bag.SetProperty(prop.Name, customProp);
            if (prop.Type == PropType.Sheet && ss != null)
            {
                foreach (var sheet in ss.Nodes.SelectMany(s => s.GetSheets()))
                {
                    var sheetBag = sheet.sheet.GetCustomPropertyBag();
                    sheetBag?.AddCustomProperty(sheet.sheet, prop);
                }
            }
        }
        // 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();
            }
        }