// 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);
        }
        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);
                }
            }
        }