Create .dst file for a drawing C#

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm getting a little more familiar with the AutoCAD API but find myself needing a little assistance. I'm trying to write a method that will count the number of sheets in a particular .dwg file. The function need's the sheet set .dst file for the drawing in order to proceed, and currently I've been making the .dst files manually using the wizard in AutoCAD. Is there a way I could generate .dst files programatically for a given .dwg file? I found a few C# code snippets that mention how to create a sheet set, but these create generic .dst files since the .dwg file is never referenced in any was as the desired drawing I'm trying to target. Any help is greatly appreciated! I'm using AutoCAD 2018 (R22) if that makes any difference. Below is the example code I found for generating sheet sets
[CommandMethod("CreateSheetSet")]
public static void CreateSheetSet()
{
// create the Sheet Set Manager Object
var sheetSetManager = new ACSMCOMPONENTS22Lib.AcSmSheetSetMgr();
// Create a new sheet set file
var sheetSetDB = sheetSetManager.CreateDatabase(@"C:\Some Folder\TestSheetSet1.dst", "", true);
// Get the sheet set from the database
var sheetSet = sheetSetDB.GetSheetSet();
// Lock the database before making any changes
if (LockDatabase(sheetSetDB, true) == true)
{
// Set the name and description
sheetSet.SetName("Testing-CPT_01");
sheetSet.SetDesc("This is my first sheet set description.");
// Unlock the database
LockDatabase(sheetSetDB, false);
// Return the name and description of the sheet set in a messagebox
MessageBox.Show($"Sheet set name: {sheetSetDB.GetSheetSet().GetName()}.\nSheet set desc: {sheetSetDB.GetSheetSet().GetDesc()}.");
}
else
{
MessageBox.Show("Sheet set could not be opened for write.");
}
// Close the sheet set
sheetSetManager.Close(sheetSetDB);
}