private void button1_Click(object sender, EventArgs e)
        {
            DrawingHandler MyDrawingHandler = new DrawingHandler();

            PrintAttributes printAttributes = new PrintAttributes();

            printAttributes.Scale = 1.0;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies       = 1;
            printAttributes.Orientation          = DotPrintOrientationType.Auto;
            printAttributes.PrintArea            = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance      = "PDF_594x420";

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                while (SelectedDrawings.MoveNext())
                {
                    Drawing currentDrawing = SelectedDrawings.Current;

                    //Get print attributes: we need only PrinterInstance
                    MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes);
                }
            }
        }
        private bool WriteCurrentDrawing(Drawing currentDrawing, string PrinterInstance)
        {
            bool            Result           = false;
            DrawingHandler  MyDrawingHandler = new DrawingHandler();
            PrintAttributes printAttributes  = new PrintAttributes();

            printAttributes.Scale = 1.0;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies       = 1;
            printAttributes.Orientation          = DotPrintOrientationType.Auto;
            printAttributes.PrintArea            = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance      = PrinterInstance;

            Result = MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes);

            return(Result);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            DrawingHandler MyDrawingHandler = new DrawingHandler();

            PrintAttributes printAttributes = new PrintAttributes();
            printAttributes.Scale = 1.0;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies = 1;
            printAttributes.Orientation = DotPrintOrientationType.Auto;
            printAttributes.PrintArea = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance = "PDF_594x420";

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                while (SelectedDrawings.MoveNext())
                {
                    Drawing currentDrawing = SelectedDrawings.Current;

                    //Get print attributes: we need only PrinterInstance
                    MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes);
                }
            }
        }
        private bool WriteCurrentDrawing(Drawing currentDrawing, string PrinterInstance)
        {
            bool Result = false;
            DrawingHandler MyDrawingHandler = new DrawingHandler();
            PrintAttributes printAttributes = new PrintAttributes();
            printAttributes.Scale = 1.0;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies = 1;
            printAttributes.Orientation = DotPrintOrientationType.Auto;
            printAttributes.PrintArea = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance = PrinterInstance;

            Result = MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes);

            return Result;
        }
        private bool PrintToFile(Drawing currentDrawing)
        {
            bool Result = false;
            double scale = 1.0;

            if (rbtnSCALE.Checked)
            {
                //get scale of the first view
                //scale = GetScaleFromTheView();
            }

            DrawingHandler MyDrawingHandler = new DrawingHandler();
            PrintAttributes printAttributes = new PrintAttributes();
            printAttributes.Scale = scale;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies = 1;
            printAttributes.Orientation = DotPrintOrientationType.Auto;
            printAttributes.PrintArea = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance = "DWG";

            string DrawingType = GetDrawingTypeCharacter(currentDrawing);

            /*
            set XS_DRAWING_PLOT_FILE_DIRECTORY=.\PlotFiles
            set XS_DRAWING_PLOT_FILE_NAME_A=%%UDA:PROJECT_USERFIELD_1%%-%%NAME.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
            set XS_DRAWING_PLOT_FILE_NAME_W=%%UDA:PROJECT_USERFIELD_1%%-%%NAME.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
            set XS_DRAWING_PLOT_FILE_NAME_C=%%UDA:PROJECT_USERFIELD_1%%-%%NAME.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
            set XS_DRAWING_PLOT_FILE_NAME_G=%%UDA:PROJECT_USERFIELD_1%%-%%TITLE.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
            set XS_DRAWING_PLOT_FILE_NAME_M=%%UDA:PROJECT_USERFIELD_1%%-%%TITLE.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
             */

            //string output_path = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_DIRECTORY");
            string output_path = "c:\\pdf";
            string output_file = "out.dwg";

            Model CurrentModel = new Model();
            ProjectInfo ProjectInfo = CurrentModel.GetProjectInfo();
            if (CurrentModel.GetConnectionStatus())
            {
                output_file = ProjectInfo.ProjectNumber;
            }

            string DrawingName = "";

            //TSM.Operations.Operation.DisplayPrompt("DrawingType" + DrawingType);

            switch (DrawingType)
            {
                case "A":
                //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_A");
                case "W":
                //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_W");
                case "C":
                    //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_C");
                    DrawingName = currentDrawing.Mark;
                    DrawingName = RemoveBrackets(DrawingName);
                    break;
                case "G":
                //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_G");
                case "M":
                    //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_M");
                    DrawingName = currentDrawing.Name;
                    break;
                default:
                    goto case "A";
            }

            DrawingName = DrawingName.Replace('.', '-');
            output_file += "-" + DrawingName + ".dwg";

            if (!String.IsNullOrEmpty(output_path) && !String.IsNullOrEmpty(output_file))
                Result = MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes, output_path + "\\" + output_file);

            return Result;
        }
        private bool PrintToFile(Drawing currentDrawing)
        {
            bool   Result = false;
            double scale  = 1.0;

            if (rbtnSCALE.Checked)
            {
                //get scale of the first view
                //scale = GetScaleFromTheView();
            }

            DrawingHandler  MyDrawingHandler = new DrawingHandler();
            PrintAttributes printAttributes  = new PrintAttributes();

            printAttributes.Scale = scale;
            printAttributes.PrintToMultipleSheet = false;
            printAttributes.NumberOfCopies       = 1;
            printAttributes.Orientation          = DotPrintOrientationType.Auto;
            printAttributes.PrintArea            = DotPrintAreaType.EntireDrawing;
            printAttributes.PrinterInstance      = "DWG";

            string DrawingType = GetDrawingTypeCharacter(currentDrawing);

            /*
             * set XS_DRAWING_PLOT_FILE_DIRECTORY=.\PlotFiles
             * set XS_DRAWING_PLOT_FILE_NAME_A=%%UDA:PROJECT_USERFIELD_1%%-%%NAME.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
             * set XS_DRAWING_PLOT_FILE_NAME_W=%%UDA:PROJECT_USERFIELD_1%%-%%NAME.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
             * set XS_DRAWING_PLOT_FILE_NAME_C=%%UDA:PROJECT_USERFIELD_1%%-%%NAME.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
             * set XS_DRAWING_PLOT_FILE_NAME_G=%%UDA:PROJECT_USERFIELD_1%%-%%TITLE.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
             * set XS_DRAWING_PLOT_FILE_NAME_M=%%UDA:PROJECT_USERFIELD_1%%-%%TITLE.-%%%%REV_MARK?_Rev%%%%REV_MARK%%
             */

            //string output_path = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_DIRECTORY");
            string output_path = "c:\\pdf";
            string output_file = "out.dwg";

            Model       CurrentModel = new Model();
            ProjectInfo ProjectInfo  = CurrentModel.GetProjectInfo();

            if (CurrentModel.GetConnectionStatus())
            {
                output_file = ProjectInfo.ProjectNumber;
            }

            string DrawingName = "";

            //TSM.Operations.Operation.DisplayPrompt("DrawingType" + DrawingType);

            switch (DrawingType)
            {
            case "A":
            //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_A");
            case "W":
            //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_W");
            case "C":
                //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_C");
                DrawingName = currentDrawing.Mark;
                DrawingName = RemoveBrackets(DrawingName);
                break;

            case "G":
            //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_G");
            case "M":
                //output_file = Environment.GetEnvironmentVariable("XS_DRAWING_PLOT_FILE_NAME_M");
                DrawingName = currentDrawing.Name;
                break;

            default:
                goto case "A";
            }

            DrawingName  = DrawingName.Replace('.', '-');
            output_file += "-" + DrawingName + ".dwg";

            if (!String.IsNullOrEmpty(output_path) && !String.IsNullOrEmpty(output_file))
            {
                Result = MyDrawingHandler.PrintDrawing(currentDrawing, printAttributes, output_path + "\\" + output_file);
            }

            return(Result);
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string printer = cmbPrinter.Text;
                string size    = "";
                double scale   = 1;

                PrintAttributes printAttributes = new PrintAttributes();
                printAttributes.ScalingType          = DotPrintScalingType.Scale;
                printAttributes.PrintToMultipleSheet = false;
                printAttributes.NumberOfCopies       = 1;
                printAttributes.Orientation          = DotPrintOrientationType.Auto;
                printAttributes.PrintArea            = DotPrintAreaType.EntireDrawing;

                DrawingEnumerator drawingEnum = drawingHandler.GetDrawingSelector().GetSelected();
                while (drawingEnum.MoveNext())
                {
                    Drawing drawing = (Drawing)drawingEnum.Current;

                    for (int i = 0; i < printerNames.Count; i++)
                    {
                        string printerName = printerNames[i].ToString();
                        if (printerName == cmbPrinter.Text)
                        {
                            double printerScale;
                            bool   printerScaleBool = double.TryParse(printerScales[i].ToString(), out printerScale);

                            if (printerScaleBool)
                            {
                                for (int c = 0; c < papersizeDimensions.Count; c++)
                                {
                                    Tekla.Structures.Drawing.Size m = (Tekla.Structures.Drawing.Size)papersizeDimensions[c];
                                    if (drawing.Layout.SheetSize.Height == m.Height && drawing.Layout.SheetSize.Width == m.Width)
                                    {
                                        size = (string)papersizeNames[c];
                                    }
                                }

                                scale = printerScale;
                            }
                            else
                            {
                                if (cmbSize.Text != "Auto")
                                {
                                    for (int c = 0; c < printsizeNames.Count; c++)
                                    {
                                        if (cmbSize.Text == printsizeNames[c].ToString())
                                        {
                                            size = printsizeNames[c].ToString();
                                            Tekla.Structures.Drawing.Size n = (Tekla.Structures.Drawing.Size)printsizeDimensions[c];
                                            scale = n.Width / drawing.Layout.SheetSize.Width;
                                            scale = double.Parse(scale.ToString("F2"));
                                        }
                                    }
                                }

                                else if (cmbSize.Text == "Auto")
                                {
                                    for (int c = 0; c < papersizeNames.Count; c++)
                                    {
                                        Tekla.Structures.Drawing.Size m = (Tekla.Structures.Drawing.Size)papersizeDimensions[c];
                                        if (drawing.Layout.SheetSize.Height == m.Height && drawing.Layout.SheetSize.Width == m.Width)
                                        {
                                            size  = papersizeAutoPrintsizeNames[c].ToString();
                                            scale = double.Parse(papersizeAutoScales[c].ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }

                    printAttributes.Scale           = scale;
                    printAttributes.PrinterInstance = printer + "-" + size;
                    drawingHandler.PrintDrawing(drawing, printAttributes);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }