コード例 #1
0
        /// <summary> Alter and update the ViewSheetData package on a view sheet. </summary>
        ///
        /// <param name="sheetName"> Name of the ViewSheet to create. </param>
        ///
        /// <returns> true if it succeeds, false if it fails. </returns>
        private bool AlterViewSheetData(string sheetName)
        {
            var sheetIndex = ViewSheets.GetViewSheet(sheetName);

            if (string.IsNullOrEmpty(sheetName) && !this.ShowMessage($"Could not find a sheet named {sheetName}.",
                                                                     LocalizationStrings.Title,
                                                                     true))
            {
                return(false);
            }

            // Get the data package attached to the ViewSheet
            var data   = new ViewSheets.ViewSheetData();
            var result = ViewSheets.GetViewSheetData(sheetIndex, ref data);

            if (!result)
            {
                if (!this.ShowMessage($"An error occurred retrieving the data for sheet {sheetName} at sheet index {sheetIndex}.",
                                      LocalizationStrings.Title,
                                      true))
                {
                    return(false);
                }
            }

            // Now make some changes and push those back to Mastercam...
            data.WireframeColor     = 66;    // Change the wireframe color settings.
            data.ConstructionDepthZ = 0.25;  // Alter the construction depth.
            data.VisibleLevels.Add(101);     // Add a level to the level list for this sheet.

            // Update the sheet
            result = ViewSheets.SetViewSheetData(sheetIndex, data);
            if (!result)
            {
                if (!this.ShowMessage($"An error occurred updating the data for sheet {sheetName} at sheet index {sheetIndex}.",
                                      LocalizationStrings.Title,
                                      true))
                {
                    return(false);
                }
            }

            return(result);
        }