// 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
        private void IAcSmEvents_OnChanged(AcSmEvent ev, IAcSmPersist comp)
        {
            Autodesk.AutoCAD.ApplicationServices.Document activeDocument = default(Autodesk.AutoCAD.ApplicationServices.Document);
            activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            AcSmSheet  oSheet  = default(AcSmSheet);
            AcSmSubset oSubset = default(AcSmSubset);

            if (ev == AcSmEvent.ACSM_DATABASE_OPENED)
            {
                activeDocument.Editor.WriteMessage("\n" + comp.GetDatabase().GetFileName() + " was opened.");
            }
            if (ev == AcSmEvent.ACSM_DATABASE_CHANGED)
            {
                activeDocument.Editor.WriteMessage("\n" + comp.GetDatabase().GetFileName() + " database changed.");
            }
            if (ev == AcSmEvent.SHEET_DELETED)
            {
                oSheet = (AcSmSheet)comp;
                activeDocument.Editor.WriteMessage("\n" + oSheet.GetName() + " was deleted.");
            }
            if (ev == AcSmEvent.SHEET_SUBSET_CREATED)
            {
                oSubset = (AcSmSubset)comp;
                activeDocument.Editor.WriteMessage("\n" + oSubset.GetName() + " was created.");
            }
            if (ev == AcSmEvent.SHEET_SUBSET_DELETED)
            {
                oSubset = (AcSmSubset)comp;
                activeDocument.Editor.WriteMessage("\n" + oSubset.GetName() + " was deleted.");
            }
        }
 public static Database SetOwner(Database database, IAcSmPersist owner)
 {
     if (database != null)
     {
         database.Owner = owner;
         return(database);
     }
     else
     {
         return(null);
     }
 }
        public IList <AMRSheet> GetSheets()
        {
            IAcSmEnumComponent sheetEnumerator = _currentSheetSet.GetSheetEnumerator();

            sheetEnumerator.Reset();
            IList <AMRSheet> sheets  = new List <AMRSheet>();
            IAcSmPersist     curItem = sheetEnumerator.Next();

            while (curItem != null)
            {
                if (curItem is AcSmSheet)
                {
                    AcSmSheet comp = (AcSmSheet)curItem;
                    sheets.Add(new AMRSheet(comp));
                }
                curItem = sheetEnumerator.Next();
            }
            curItem         = null;
            sheetEnumerator = null;
            return(sheets);
        }
        public void StepThroughOpenSheetSets()
        {
            // Get a reference to the Sheet Set Manager object
            IAcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr();

            // Get the loaded databases
            IAcSmEnumDatabase enumDatabase = sheetSetManager.GetDatabaseEnumerator();

            // Get the first open database
            IAcSmPersist item = enumDatabase.Next();

            string customMessage = "";

            // If a database is open continue
            if ((item != null))
            {
                int count = 0;

                // Step through the database enumerator
                while ((item != null))
                {
                    // Append the file name of the open sheet set to the output string
                    customMessage = customMessage + "\n" + item.GetDatabase().GetFileName();

                    // Get the next open database and increment the counter
                    item  = enumDatabase.Next();
                    count = count + 1;
                }

                customMessage = "Sheet sets open: " + count.ToString() + customMessage;
            }
            else
            {
                customMessage = "No sheet sets are currently open.";
            }

            // Display the custom message
            MessageBox.Show(customMessage);
        }
        // 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();
            }
        }
Exemple #7
0
 void IAcSmEvents.OnChanged(AcSmEvent ev, IAcSmPersist comp)
 {
     IAcSmEvents_OnChanged(ev, comp);
 }
 public static void SetOwner(IAcSmPersist pOwner)
 {
     throw new NotImplementedException();
 }
 public static void NotifyRegisteredEventHandlers(AcSmEvent eventcode, IAcSmPersist comp)
 {
     throw new NotImplementedException();
 }