Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In a similar post, the sheet set IAcSMComponent was cast to an AcSmSheet to access the sheet set properties GetName() GetNumber() etc. In my case it returns a NullReferenceException. I suspect this is because the component "Deck" is a subset.
How can I get access to the sheets inside of "Deck" to get the sheet set properties?
public void GetSheetSetProperties()
{
var sheetSetManager = new AcSmSheetSetMgr();
var databaseEnum = sheetSetManager.GetDatabaseEnumerator();
// Get the first database in list.
AcSmDatabase database = databaseEnum.Next();
database.LockDb(database);
// Get the sheet set in the database.
AcSmSheetSet sheetSet = database.GetSheetSet();
var sheetEnum = sheetSet.GetSheetEnumerator();
// This gets the main component named "Deck" in the example tree.
var component = sheetEnum.Next();
#region DoesNotWork
// Cast component to dummy sheet to get properties.
var dummySheet = component as AcSmSheet;
// Creates: System.NullReferenceException: 'Object reference not set to an instance of an object.'
string ssName = dummySheet.GetName();
string ssNumber = dummySheet.GetNumber();
#endregion
// TODO: Get the actual sheets i.e. the sheets under "Deck"
}
Thank you.
Solved! Go to Solution.