コード例 #1
0
        // 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);
        }
コード例 #2
0
        // 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();
            }
        }