public SubsetNode(AcSmSubset subset, SheetSet ss) : base(ss) { this.subset = subset; Name = subset.GetName(); Nodes = GetNodes(); }
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 void CreateSheetSet_WithSubset() { // User Input: editor equals command line // To talk to the user you use the command line, aka the editor Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PromptResult pr = ed.GetFileNameForSave("Hello Nadia, Where would you would like to save the new Sheet Set?"); PromptStringOptions pso = new PromptStringOptions("\nHello Nadia! \nWhat will be the name of the new Sheet Set?"); pso.AllowSpaces = true; PromptResult prSheetSetName = ed.GetString(pso); PromptStringOptions psoDescription = new PromptStringOptions("\nHello Nadia! \nWhat will be the description of the new Sheet Set?"); psoDescription.AllowSpaces = true; PromptResult prSheetSetDescription = ed.GetString(psoDescription); // Get a reference to the Sheet Set Manager object IAcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr(); // Create a new sheet set file //AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase("C:\\Datasets\\CP318-4\\CP318-4.dst", "", true); AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase(pr.StringResult, "", true); // Get the sheet set from the database AcSmSheetSet sheetSet = sheetSetDatabase.GetSheetSet(); // Attempt to lock the database if (LockDatabase(ref sheetSetDatabase, true) == true) { // Set the name and description of the sheet set sheetSet.SetName(prSheetSetName.StringResult); sheetSet.SetDesc(prSheetSetDescription.StringResult); // Create two new subsets AcSmSubset subset = default(AcSmSubset); //subset = CreateSubset(sheetSetDatabase, "Plans", "Building Plans", "", "C:\\Datasets\\CP318-4\\CP318-4.dwt", "Sheet", false); subset = CreateSubset(sheetSetDatabase, "Submittals", "Project Submittals", "", @"C:\Users\Robert\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet", false); //subset = CreateSubset(sheetSetDatabase, "Elevations", "Building Elevations", "", "C:\\Datasets\\CP318-4\\CP318-4.dwt", "Sheet", true); subset = CreateSubset(sheetSetDatabase, "As Builts", "Project As Builts", "", @"C:\Users\Robert\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet", true); // Unlock the database LockDatabase(ref sheetSetDatabase, false); } else { // Display error message MessageBox.Show("Sheet set could not be opened for write."); } // Close the sheet set sheetSetManager.Close(sheetSetDatabase); }
private AcSmSubset CreateSubset(AcSmDatabase sheetSetDatabase, string name, string description, string newSheetLocation, string newSheetDWTLocation, string newSheetDWTLayout, bool promptForDWT) { // Create a subset with the provided name and description AcSmSubset subset = (AcSmSubset)sheetSetDatabase.GetSheetSet().CreateSubset(name, description); // Get the folder the sheet set is stored in string sheetSetFolder = sheetSetDatabase.GetFileName().Substring(0, sheetSetDatabase.GetFileName().LastIndexOf("\\")); // Create a reference to a File Reference object IAcSmFileReference fileReference = subset.GetNewSheetLocation(); // Check to see if a path was provided, if not default // to the location of the sheet set if (!string.IsNullOrEmpty(newSheetLocation)) { fileReference.SetFileName(newSheetLocation); } else { fileReference.SetFileName(sheetSetFolder); } // Set the location for new sheets added to the subset subset.SetNewSheetLocation(fileReference); // Create a reference to a Layout Reference object AcSmAcDbLayoutReference layoutReference = default(AcSmAcDbLayoutReference); layoutReference = subset.GetDefDwtLayout(); // Check to see that a default DWT location and name was provided if (!string.IsNullOrEmpty(newSheetDWTLocation)) { // Set the template location and name of the layout //for the Layout Reference object layoutReference.SetFileName(newSheetDWTLocation); layoutReference.SetName(newSheetDWTLayout); // Set the Layout Reference for the subset subset.SetDefDwtLayout(layoutReference); } // Set the Prompt for Template option of the subset subset.SetPromptForDwt(promptForDWT); return(subset); }
public void SyncProperties() { // User Input: editor equals command line // To talk to the user you use the command line, aka the editor Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PromptResult pr1 = ed.GetFileNameForOpen("Hello Nadia, Please select the Sheet Set you would like to edit."); PromptStringOptions pso = new PromptStringOptions("\nHello Nadia! \nWhat version # is the drawing at?"); //pso.DefaultValue = @"C:\Users\Robert\Documents\AutoCAD Sheet Sets\Expedia.dst"; //pso.UseDefaultValue = true; pso.AllowSpaces = true; PromptResult pr = ed.GetString(pso); string versionNumber = pr.StringResult; pso = new PromptStringOptions("\nHello Nadia! \nWhat is the version issue date?"); pr = ed.GetString(pso); string versionIssueDate = pr.StringResult; // Get a reference to the Sheet Set Manager object IAcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr(); // Create a new sheet set file //AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase("C:\\Datasets\\CP318-4\\CP318-4.dst", "", true); //AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase(@"C:\Users\rhale\Documents\AutoCAD Sheet Sets\Expedia.dst", "", true); // Open a Sheet Set file AcSmDatabase sheetSetDatabase = default(AcSmDatabase); //sheetSetDatabase = sheetSetManager.OpenDatabase("C:\\Program Files\\AutoCAD 2010\\Sample\\Sheet Sets\\Architectural\\IRD Addition.dst", false); //sheetSetDatabase = sheetSetManager.OpenDatabase(@"C:\Users\rhale\Documents\AutoCAD Sheet Sets\Expedia.dst", false); sheetSetDatabase = sheetSetManager.OpenDatabase(pr1.StringResult, false); // Get the sheet set from the database AcSmSheetSet sheetSet = sheetSetDatabase.GetSheetSet(); // Attempt to lock the database if (LockDatabase(ref sheetSetDatabase, true) == true) { // Get the folder the sheet set is stored in string sheetSetFolder = null; sheetSetFolder = sheetSetDatabase.GetFileName().Substring(0, sheetSetDatabase.GetFileName().LastIndexOf("\\")); // Set the default values of the sheet set //SetSheetSetDefaults(sheetSetDatabase, "CP318-4", "AU2009 Sheet Set Object Demo", sheetSetFolder, "C:\\Datasets\\CP318-4\\CP318-4.dwt", "Sheet"); SetSheetSetDefaults(sheetSetDatabase, "Expedia Sheet Set", "ABF Sheet Set Object Demo", sheetSetFolder, @"C:\Users\rhale\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet"); // Create a sheet set property SetCustomProperty(sheetSet, "Project Approved By", "Erin Tasche", PropertyFlags.CUSTOM_SHEETSET_PROP); // Create sheet properties //SetCustomProperty(sheetSet, "Checked By", "LAA", PropertyFlags.CUSTOM_SHEET_PROP); //SetCustomProperty(sheetSet, "Complete Percentage", "0%", PropertyFlags.CUSTOM_SHEET_PROP); SetCustomProperty(sheetSet, "Version #", versionNumber, PropertyFlags.CUSTOM_SHEET_PROP); SetCustomProperty(sheetSet, "Version Issue Date", versionIssueDate, PropertyFlags.CUSTOM_SHEET_PROP); //AddSheet(sheetSetDatabase, "Title Page", "Project Title Page", "Title Page", "T1"); // Create two new subsets AcSmSubset subset = default(AcSmSubset); //subset = CreateSubset(sheetSetDatabase, "Plans", "Building Plans", "", "C:\\Datasets\\CP318-4\\CP318-4.dwt", "Sheet", false); subset = CreateSubset(sheetSetDatabase, "Submittals", "Project Submittals", "", @"C:\Users\Robert\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet", false); //subset = CreateSubset(sheetSetDatabase, "Elevations", "Building Elevations", "", "C:\\Datasets\\CP318-4\\CP318-4.dwt", "Sheet", true); subset = CreateSubset(sheetSetDatabase, "As Builts", "Project As Builts", "", @"C:\Users\Robert\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet", true); // Add a sheet property //SetCustomProperty(sheetSet, "Drafted By", "KMA", PropertyFlags.CUSTOM_SHEET_PROP); // Add a subset property SetCustomProperty(sheetSet, "Count", "0", PropertyFlags.CUSTOM_SHEETSET_PROP); // Sync the properties of the sheet set with the sheets and subsets SyncProperties(sheetSetDatabase); // Unlock the database LockDatabase(ref sheetSetDatabase, false); } else { // Display error message MessageBox.Show("Sheet set could not be opened for write."); } // Close the sheet set sheetSetManager.Close(sheetSetDatabase); }
public void CreateSheetSet_AddCustomProperty() { // Get a reference to the Sheet Set Manager object IAcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr(); // Create a new sheet set file //AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase("C:\\Datasets\\CP318-4\\CP318-4.dst", "", true); //AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase("C:\\Datasets\\CP318-4\\CP318-4.dst", "", true); //AcSmDatabase sheetSetDatabase = sheetSetManager.OpenDatabase(@"C:\Users\rhale\Documents\AutoCAD Sheet Sets\Expedia.dst", true); //AcSmDatabase sheetSetDatabase = sheetSetManager.(@"C:\Users\rhale\Documents\AutoCAD Sheet Sets\Expedia.dst", true); // Open a Sheet Set file AcSmDatabase sheetSetDatabase = default(AcSmDatabase); //sheetSetDatabase = sheetSetManager.OpenDatabase("C:\\Program Files\\AutoCAD 2010\\Sample\\Sheet Sets\\Architectural\\IRD Addition.dst", false); sheetSetDatabase = sheetSetManager.OpenDatabase(@"C:\Users\rhale\Documents\AutoCAD Sheet Sets\Expedia.dst", false); // Get the sheet set from the database AcSmSheetSet sheetSet = sheetSetDatabase.GetSheetSet(); // Attempt to lock the database if (LockDatabase(ref sheetSetDatabase, true) == true) { // Get the folder the sheet set is stored in string sheetSetFolder = null; sheetSetFolder = sheetSetDatabase.GetFileName().Substring(0, sheetSetDatabase.GetFileName().LastIndexOf("\\")); // Set the default values of the sheet set SetSheetSetDefaults(sheetSetDatabase, "My Expedia Sheet Set", "A&B Fabricators Sheet Set Object Demo", sheetSetFolder, @"C:\Users\rhale\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet"); // Create a sheet set property SetCustomProperty(sheetSet, "Project Approved By", "Erin Tasche", PropertyFlags.CUSTOM_SHEETSET_PROP); // Create sheet properties SetCustomProperty(sheetSet, "Checked By", "NK", PropertyFlags.CUSTOM_SHEET_PROP); SetCustomProperty(sheetSet, "Complete Percentage", "90%", PropertyFlags.CUSTOM_SHEET_PROP); SetCustomProperty(sheetSet, "Version #", "D", PropertyFlags.CUSTOM_SHEET_PROP); SetCustomProperty(sheetSet, "Version Issue Date", "08/29/19", PropertyFlags.CUSTOM_SHEET_PROP); //AddSheet(sheetSetDatabase, "Title Page", "Project Title Page", "Title Page", "T1"); // Create two new subsets AcSmSubset subset = default(AcSmSubset); subset = CreateSubset(sheetSetDatabase, "Plans", "Building Plans", "", @"C:\Users\rhale\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet", false); //AddSheet(subset, "North Plan", "Northern section of building plan", "North Plan", "P1"); subset = CreateSubset(sheetSetDatabase, "Elevations", "Building Elevations", "", @"C:\Users\rhale\Documents\AutoCAD Sheet Sets\ABFStylesSS.dwt", "Sheet", true); // Sync the properties of the sheet set with the sheets and subsets SyncProperties(sheetSetDatabase); // Unlock the database LockDatabase(ref sheetSetDatabase, false); } else { // Display error message MessageBox.Show("Sheet set could not be opened for write."); } // Close the sheet set sheetSetManager.Close(sheetSetDatabase); }
/// <summary> /// Create and add a new Subset to the Sheet Set. /// </summary> /// <param name="sheetSet">The sheet set to contain the new subset.</param> /// <param name="name">The name of the new subset.</param> /// <param name="description">The optional description of the new subset.</param> /// <param name="newSheetDWTLayout">The optional layout tab of an alterante DWT to create new sheets from.</param> /// <param name="newSheetDWTLocation">The optional location of an alternate DWT to create new sheets from.</param> /// <param name="newSheetLocation">An optional new location to create new sheets for this subset.</param> /// <param name="promptForDWT">Optional setting to force the user to select a template with each new sheet.</param> /// <returns>The new subset.</returns> public static SubSet CreateNewSubset(SheetSet sheetSet, string name, string description = "", string newSheetLocation = "", string newSheetDWTLocation = "", string newSheetDWTLayout = "", bool promptForDWT = false) { SubSet retVal = null; if ((sheetSet != null) || (name != null) || (name != "")) { try {// lock the database if (Database.LockDatabase(sheetSet.Database, true)) { //create the new subset AcSmSubset newSubset = (AcSmSubset)sheetSet.BaseObject.CreateSubset(name, description); // get thet folder the sheet set is stored in IAcSmFileReference sheetSetFolder = sheetSet.BaseObject.GetNewSheetLocation(); // create a file reference IAcSmFileReference fileReference = newSubset.GetNewSheetLocation(); // check if a new path was provided, if not, default to the sheet set location if (newSheetLocation != "") { fileReference.SetFileName(newSheetLocation); } else { fileReference.SetFileName(sheetSetFolder.GetFileName()); } // set the location for new sheets added to the subset newSubset.SetNewSheetLocation(fileReference); // check if a default DWT location and name was provided if ((newSheetDWTLocation != "") && (newSheetDWTLayout != "")) { // create a reference to a layout reference object AcSmAcDbLayoutReference layoutReference = newSubset.GetDefDwtLayout(); layoutReference.SetFileName(newSheetDWTLocation); layoutReference.SetName(newSheetDWTLayout); // set the layout reference for the subset newSubset.SetDefDwtLayout(layoutReference); } // set the prompt for template option newSubset.SetPromptForDwt(promptForDWT); // create our version of a subset retVal = new SubSet((AcSmSubset)newSubset); } // if it couldn't be locked, fail else { return(null); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { // unlock the database Database.LockDatabase(sheetSet.Database, false); } } return(retVal); }
// constuctors need to be static methods in order to show up in the Create category internal SubSet(AcSmSubset subsetFromSSMgr) { _curSubSet = subsetFromSSMgr; _curSubSet2 = (IAcSmSubset2)subsetFromSSMgr; }