How to apply sheet properties modifications to drawings

How to apply sheet properties modifications to drawings

ahmedshawkey95
Advocate Advocate
358 Views
0 Replies
Message 1 of 1

How to apply sheet properties modifications to drawings

ahmedshawkey95
Advocate
Advocate

Hi All,

I'm developing an automation plugin that allows me to modify properties of some Sheets in a selected Sheet Set at once using WPF window as shown below, and the following code updates the Description property for all sheets but when I tried to open sheet properties from AutoCAD, it shows the old value thus the attributes fields that use this property don't change.

 

How to apply or sync my changes to the drawings?

 

ahmedshawkey95_0-1605874279348.pngahmedshawkey95_1-1605874362319.png

 

 private void BtnOk_OnClick(object sender, RoutedEventArgs e)
        {
            AcSmSheetSetMgr mgr = new AcSmSheetSetMgr();
            AcSmDatabase db;
            try
            {
                db = mgr.OpenDatabase(_activeSheetSetPath, false);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message,
                    "Can't Open Sheet Set", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            if (db.GetLockStatus() != AcSmLockStatus.AcSmLockStatus_UnLocked)
            {
                MessageBox.Show($"The selected sheet set is already opened by another task. Try to close it first.",
                    "Sheet Set Is Locked", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            db.LockDb(db);
            AcSmSheetSet ss = db.GetSheetSet();
            //var allItems = _viewModel.Items.SelectMany(i => i.GetAllChildren()).ToList();
            var iterator = ss.GetSheetEnumerator();
            IAcSmComponent item = iterator.Next();
            while (item != null)
            {
                //Here I'm updating all properties and custom properties but I changed it for simplicity
                if (item is AcSmSheet sheet)
                {
                    sheet.SetDesc("Updated Description");//this line updates the sheet description but doesn't affect the sheet properties form in AutoCAD
                }
                item = iterator.Next();
            }

            db.UnlockDb(db, true);
            mgr.Close(db);
            Close();
        }

 

 

359 Views
0 Replies
Replies (0)