Get full path of dwg files from a sheetset

Get full path of dwg files from a sheetset

Miralkong
Advocate Advocate
681 Views
2 Replies
Message 1 of 3

Get full path of dwg files from a sheetset

Miralkong
Advocate
Advocate

Hi, guys. I want to get the full path of every dwg files from a sheetset. What I've tried  was as following:

 // Create a new SheetSetManager
            AcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr();

            // Declare a AcSmDatabase variant
            AcSmDatabase acSheetSetDb = null;

            try
            {
                // Get the database of specified dst file
                acSheetSetDb = sheetSetManager.OpenDatabase(dstFilePath, false);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.ToString());
            }           

            List<string> dwgFilePathList = new List<string>();

            try
            {
                acSheetSetDb.LockDb(acSheetSetDb);

                // Get the sheet set object
                AcSmSheetSet acSheetSet = acSheetSetDb.GetSheetSet();

                // Get drawings' title sorted by subcategory                
                dwgFilePathList = ProcessEnumerator(acSheetSet.GetSheetEnumerator());
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                acSheetSetDb.UnlockDb(acSheetSetDb, true);
                sheetSetManager.Close(acSheetSetDb);
            }

By doing this, I can only get the file name of dwg file(like "firstFloor.dwg"). Is there anyone know how to get the full path? Thanks a lot.

0 Likes
Accepted solutions (1)
682 Views
2 Replies
Replies (2)
Message 2 of 3

Alexander.Rivilis
Mentor
Mentor
Accepted solution

Check ResolveFileName method of AcSmAcDbLayoutReference class

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 3

Miralkong
Advocate
Advocate

Thanks a lot. It works.

And for those who need more details. Below is what I tried:

public List<string> GetDrawingPathFromDst(string dstFilePath)
        {
            // Create a new SheetSetManager
            AcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr();

            // Declare a AcSmDatabase variant
            AcSmDatabase acSheetSetDb = null;

            try
            {
                // Get the database of specified dst file
                acSheetSetDb = sheetSetManager.OpenDatabase(dstFilePath, false);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.ToString());
            }           

            List<string> dwgFilePathList = new List<string>();

            try
            {
                acSheetSetDb.LockDb(acSheetSetDb);

                // Get the sheet set object
                AcSmSheetSet acSheetSet = acSheetSetDb.GetSheetSet();

                // Get drawings' title sorted by subcategory   
                dwgFilePathList = ProcessEnumerator(acSheetSet.GetSheetEnumerator());
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                acSheetSetDb.UnlockDb(acSheetSetDb, true);
                sheetSetManager.Close(acSheetSetDb);
            }

            return dwgFilePathList;
        }
 private List<string> ProcessEnumerator(IAcSmEnumComponent iter)
        {
            List<string> filePathList = new List<string>();

            IAcSmComponent item = iter.Next();

            while (item != null)
            {
                string type = item.GetTypeName();

                if(type == "AcSmSheet")
                {
                    AcSmSheet sh = (AcSmSheet)item;
                    string filePath = sh.GetLayout().ResolveFileName();
                    if (filePath != null || filePath.Length == 0)
                        filePathList.Add(filePath);
                }

                item = iter.Next();
            }
            return filePathList;
        }
0 Likes