// Set/create a custom sheet or sheet set property private void SetCustomProperty(IAcSmPersist owner, string propertyName, object propertyValue, PropertyFlags sheetSetFlag) { // Create a reference to the Custom Property Bag AcSmCustomPropertyBag customPropertyBag = default(AcSmCustomPropertyBag); if (owner.GetTypeName() == "AcSmSheet") { AcSmSheet sheet = (AcSmSheet)owner; customPropertyBag = sheet.GetCustomPropertyBag(); } else { AcSmSheetSet sheetSet = (AcSmSheetSet)owner; customPropertyBag = sheetSet.GetCustomPropertyBag(); } // Create a reference to a Custom Property Value AcSmCustomPropertyValue customPropertyValue = new AcSmCustomPropertyValue(); customPropertyValue.InitNew(owner); // Set the flag for the property customPropertyValue.SetFlags(sheetSetFlag); // Set the value for the property customPropertyValue.SetValue(propertyValue); // Create the property customPropertyBag.SetProperty(propertyName, customPropertyValue); }
public void CreateSheetSet() { // 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); //pso.DefaultValue = @"C:\Users\Robert\Documents\AutoCAD Sheet Sets\Expedia.dst"; //pso.UseDefaultValue = true; // works... // Get a reference to the Sheet Set Manager object IAcSmSheetSetMgr sheetSetManager = new AcSmSheetSetMgr(); // Create a new sheet set file //AcSmDatabase sheetSetDatabase = sheetSetManager.CreateDatabase(@"C:\Users\Robert\Documents\AutoCAD Sheet Sets\ExpediaSheetSetDemo.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("ExpediaSheetSetTest"); sheetSet.SetName(prSheetSetName.StringResult); //sheetSet.SetDesc("Aluminum Bronze Fabricator's Sheet Set Object Demo"); sheetSet.SetDesc(prSheetSetDescription.StringResult); // Unlock the database LockDatabase(ref sheetSetDatabase, false); // Return the name and description of the sheet set MessageBox.Show("Sheet Set Name: " + sheetSetDatabase.GetSheetSet().GetName() + "\nSheet Set Description: " + sheetSetDatabase.GetSheetSet().GetDesc()); } else { // Display error message MessageBox.Show("Sheet set could not be opened for write."); } // Close the sheet set sheetSetManager.Close(sheetSetDatabase); }
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); }
public SheetSet(AcSmDatabase ssDb, SSOptions options) { this.ssDb = ssDb; this.options = options; ss = ssDb.GetSheetSet(); if (ss == null) { throw new Exception("Пустая подшивка"); } Name = ss.GetName(); File = ssDb.GetFileName(); }
private void Update() { var nodes = new ObservableCollection <ISSNode>(); ss = ssDb.GetSheetSet(); foreach (var item in SsToList(ss.GetSheetEnumerator(), e => e.Next())) { nodes.Add(GetNode(item)); } Props = GetProps(); Nodes = nodes; }
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); }
static void Main(string[] args) { //*****parse the command-line arguments***** //for now, I will simply hard code these values. String nameOfSheetsetFile = "C:\\work\\ec-18-013_les_schwab_397\\main_sheet_set.dst"; String nameOfPdfOutputFile = "C:\\work\\ec-18-013_les_schwab_397\\out.pdf"; //TO DO: parse and verify the real command-line arguments, compose a help message. //*****read the sheetset file and construct a dsd file accordingly***** //Console.WriteLine(Microsoft.VisualBasic.Information.TypeName(new AcSmSheetSetMgr())); //Console.WriteLine(Microsoft.VisualBasic.Information.TypeName(Activator.CreateInstance(Type.GetTypeFromProgID("AcSmComponents.AcSmSheetSetMgr.23"), true))); //IAcSmSheetSetMgr sheetSetMgr; = new AcSmSheetSetMgrClass(); IAcSmSheetSetMgr sheetSetMgr; //sheetSetMgr = (IAcSmSheetSetMgr) new AcSmSheetSetMgr(); //dynamic sheetSetMgr; ////Console.WriteLine(Type.GetTypeFromProgID("AcSmComponents.AcSmSheetSetMgr.23")); ////Console.WriteLine(Type.GetTypeFromProgID("AutoCAD.Application.23")); Type t = Type.GetTypeFromProgID("AcSmComponents.AcSmSheetSetMgr.23"); sheetSetMgr = (IAcSmSheetSetMgr)Activator.CreateInstance(t, true); //dynamic sheetSetMgr = (dynamic)Activator.CreateInstance(Type.GetTypeFromProgID("AcSmComponents.AcSmSheetSetMgr.23"), true); ////try //{ // // Create a new instance of AcSmSheetSetMgr // sheetSetMgr = (dynamic)Activator.CreateInstance(Type.GetTypeFromProgID("AcSmComponents.AcSmSheetSetMgr.23"), true); //} //catch //{ // // If an instance of AcSmSheetSetMgr is not created then message and exit // Console.WriteLine("Instance of 'AcSmComponents.AcSmSheetSetMgr.23' could not be created."); // Console.WriteLine("Press any key to exit."); // Console.ReadKey(); // return; //} IAcSmDatabase sheetdb = sheetSetMgr.OpenDatabase(nameOfSheetsetFile, false); if (sheetdb.GetLockStatus() == 0) { sheetdb.LockDb(sheetdb); } //it may not be necessary tolock the sheetset, because I am only reading fromit, not writing to it. AcSmSheetSet sheetset = sheetdb.GetSheetSet(); IAcSmEnumComponent myAcSmEnumComponent = sheetset.GetSheetEnumerator(); IAcSmComponent thisAcSmComponent; while ((thisAcSmComponent = myAcSmEnumComponent.Next()) != null) { Console.WriteLine(thisAcSmComponent.GetObjectId().GetPersistObject().GetTypeName()); } if (sheetdb.GetLockStatus() != 0) { sheetdb.UnlockDb(sheetdb); } // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public AMRSheetSet() { _currentSheetSet = null; _currentDatabase = null; }
public AMRSheetSet(AcSmDatabase sheetSetDbFromMgr) { _currentDatabase = sheetSetDbFromMgr; _currentSheetSet = _currentDatabase.GetSheetSet(); }
internal SheetSet(AcSmSheetSet sheetSetFromSSMgr) { _curSheetSet = sheetSetFromSSMgr; _curSheetSet2 = (IAcSmSheetSet2)sheetSetFromSSMgr; }