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);
        }
        private void SetSheetSetDefaults(AcSmDatabase sheetSetDatabase, string name, string description,
                                         string newSheetLocation, string newSheetDWTLocation, string newSheetDWTLayout,
                                         bool promptForDWT)
        {
            // Set the Name and Description for the sheet set
            sheetSetDatabase.GetSheetSet().SetName(name);
            sheetSetDatabase.GetSheetSet().SetDesc(description);

            // Check to see if a Storage Location was provided
            if (!string.IsNullOrEmpty(newSheetLocation))
            {
                // 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 = default(IAcSmFileReference);
                fileReference = sheetSetDatabase.GetSheetSet().GetNewSheetLocation();

                // Set the default storage location based on the location of the sheet set
                fileReference.SetFileName(sheetSetFolder);

                // Set the new Sheet location for the sheet set
                sheetSetDatabase.GetSheetSet().SetNewSheetLocation(fileReference);
            }

            // Check to see if a Template was provided
            if (!string.IsNullOrEmpty(newSheetDWTLocation))
            {
                // Set the Default Template for the sheet set
                AcSmAcDbLayoutReference layoutReference = default(AcSmAcDbLayoutReference);
                layoutReference = sheetSetDatabase.GetSheetSet().GetDefDwtLayout();

                // 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 sheet set
                sheetSetDatabase.GetSheetSet().SetDefDwtLayout(layoutReference);
            }

            // Set the Prompt for Template option of the subset
            sheetSetDatabase.GetSheetSet().SetPromptForDwt(promptForDWT);
        }
Esempio n. 3
0
        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();
        }
        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);
        }
 public string GetFileName()
 {
     return(_currentDatabase.GetFileName());
 }