コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }