Ejemplo n.º 1
0
        public static void InsertNote(IDrawingDoc draw, string text, int height, double offsetX, double offsetY, IEntity entity)
        {
            double x = 0;
            double y = 0;

            if (entity != null)
            {
                entity.Select4(false, null);

                var view = (draw as IModelDoc2).ISelectionManager.GetSelectedObjectsDrawingView2(1, -1);

                var viewOutline = view.GetOutline() as double[];

                x = viewOutline[0] + offsetX;
                y = viewOutline[1] - offsetY;
            }
            else
            {
                double sheetWidth  = 0;
                double sheetHeight = 0;
                draw.IGetCurrentSheet().GetSize(ref sheetWidth, ref sheetHeight);

                x = offsetX;
                y = sheetHeight - offsetY;
            }

            var note = (draw as IModelDoc2).InsertNote(text) as INote;

            note.SetHeightInPoints(height);

            note.IGetAnnotation().SetPosition2(x, y, 0);
        }
Ejemplo n.º 2
0
        public static void InsertNote(IDrawingDoc draw, string text, NoteSize size)
        {
            int height = 0;

            switch (size)
            {
            case NoteSize.Small:
                height = 24;
                break;

            case NoteSize.Normal:
                height = 36;
                break;

            case NoteSize.Large:
                height = 64;
                break;
            }

            InsertNote(draw, text, height, 0, 0, null);
        }
Ejemplo n.º 3
0
 internal SwDrawing(IDrawingDoc drawing, ISwApplication app, IXLogger logger, bool isCreated)
     : base((IModelDoc2)drawing, app, logger, isCreated)
 {
     Sheets = new SwSheetCollection(this);
 }
Ejemplo n.º 4
0
        private static void InsertBomTable(IList<BomData> bomDataList, IDrawingDoc swDrawing, string sheetName, string templateSheet)
        {
            var existSheet = swDrawing.NewSheet3(sheetName, 9, 12, 1, 10, true, templateSheet, 0.21, 0.297, "По умолчанию");
            var nawSheetName = sheetName;
            if (!existSheet)
            {
            m1:
                var newNumber = Convert.ToInt32(nawSheetName.Replace(nawSheetName.Remove(2), "")) + 1;
                nawSheetName = sheetName.Remove(2) + newNumber;
                var exist = swDrawing.NewSheet3(nawSheetName, 9, 12, 1, 10, true, templateSheet, 0.21, 0.297, "По умолчанию");
                if (!exist)
                {
                    goto m1;
                }
            }

            swDrawing.ActivateSheet(nawSheetName);

            var myTable = swDrawing.InsertTableAnnotation(0.02, 0.292, 1, bomDataList.Count+1, 7);
            if ((myTable == null)) return;
            for (var i = 0; i < BomSettings.КоличествоСтрокНаПервомЛистеА4; i++)
            {
                myTable.SetRowHeight(i, 0.008, 0);
            }
            myTable.Title = "Таблица видов";
            myTable.BorderLineWeight = 1;
            myTable.GridLineWeight = 1;

            #region Ширина колонок

            myTable.SetRowHeight(0, 0.015, 0);
            myTable.SetColumnWidth(0, 0.006, 0);
            myTable.SetColumnWidth(1, 0.006, 0);
            myTable.SetColumnWidth(2, 0.008, 0);
            myTable.SetColumnWidth(3, 0.07, 0);
            myTable.SetColumnWidth(4, 0.063, 0);
            myTable.SetColumnWidth(5, 0.010, 0);
            myTable.SetColumnWidth(6, 0.022, 0);

            #endregion

            const int position = 1;
           
            for (var i = 0; i < bomDataList.Count(); i++)
            {
                myTable.Text[position + i, 0] = bomDataList[i].Формат;
                myTable.Text[position + i, 2] = bomDataList[i].Row;
                myTable.Text[position + i, 3] = bomDataList[i].Обозначение;
                myTable.Text[position + i, 4] = bomDataList[i].Наименование;
                myTable.Text[position + i, 5] = bomDataList[i].Количество;
                myTable.Text[position + i, 6] = bomDataList[i].Примечание;
                var наименование = bomDataList[i].Наименование;
                if (наименование == null)
                {
                    myTable.SetRowHeight(position + i, 0.008, 0);
                }
                else
                {
                    myTable.SetRowHeight(position + i, наименование.Count() < 35 ? 0.008 : 0.016, 0);
                }

                if (i <= position) continue;
                myTable.set_CellTextHorizontalJustification(position + i, 0,
                    (int) swTextJustification_e.swTextJustificationRight);
            }
        }
Ejemplo n.º 5
0
 internal SwDrawing(IDrawingDoc drawing, SwApplication app, IXLogger logger, bool isCreated)
     : base((IModelDoc2)drawing, app, logger, isCreated)
 {
     m_SheetsLazy = new Lazy <IXSheetRepository>(() => new SwSheetCollection(this));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Conert solid works drawing to pdf file.
        /// </summary>
        /// <param name="document">Document for building pdf</param>
        /// <param name="finalPath">Path to the build file</param>
        /// <returns></returns>
        private string ConvertDrwToPdf(string path)
        {
            int       Errors   = 0;
            ModelDoc2 document = SolidWorksAdapter.SldWoksAppExemplare.OpenDoc2(path, (int)swDocumentTypes_e.swDocDRAWING, false, false, true, Errors);

            try
            {
                ModelDocExtension  swModelDocExt;
                PrintSpecification printSpec;
                Sheet sheet;

                swModelDocExt = document.Extension;
                // applied to Sheet or App, Doc...
                swModelDocExt.UsePageSetup = (int)swPageSetupInUse_e.swPageSetupInUse_DrawingSheet;
                IDrawingDoc drawingDoc = document as IDrawingDoc;
                PageSetup   pageSetup;
                string[]    sheetNames  = drawingDoc.GetSheetNames();
                PdfSettings pdfSettings = new PdfSettings();
                ClearDirectory();
                int tempfileIndex = 0;
                foreach (var sheetName in sheetNames)
                {
                    //Console.WriteLine(sheetName);
                    drawingDoc.ActivateSheet(sheetName);
                    sheet     = drawingDoc.GetCurrentSheet();
                    pageSetup = sheet.PageSetup;
                    var sheetPropertis = (double[])sheet.GetProperties2();
                    pdfSettings.PrinterName = PrinterName;
                    if (!Directory.Exists(TempPdfFolder))
                    {
                        Directory.CreateDirectory(TempPdfFolder);
                    }
                    pdfSettings.SetValue("Output", string.Format(TempPdfFolder + @"\" + tempfileIndex + " temp " + sheetName + " .pdf"));
                    tempfileIndex++;
                    pdfSettings.SetValue("ShowPDF", "no");
                    pdfSettings.SetValue("ShowSettings", "never");
                    pdfSettings.SetValue("ShowSaveAS", "never");
                    pdfSettings.SetValue("ShowProgress", "no");
                    pdfSettings.SetValue("ShowProgressFinished", "no");
                    pdfSettings.SetValue("ConfirmOverwrite", "yes");
                    pdfSettings.WriteSettings(PdfSettingsFileType.RunOnce);
                    pageSetup.DrawingColor = (int)swPageSetupDrawingColor_e.swPageSetup_AutomaticDrawingColor;
                    Orientation(pageSetup, sheetPropertis);
                    printSpec             = (PrintSpecification)swModelDocExt.GetPrintSpecification();
                    printSpec.ScaleMethod = (int)swPrintSelectionScaleFactor_e.swPrintCurrentSheet;
                    printSpec.PrintToFile = false;
                    try
                    {
                        swModelDocExt.PrintOut4(PrinterName, "", printSpec);
                        System.Threading.Thread.Sleep(2000);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Possibly not fount the Bullzip PDF Printer\n" + ex.ToString());
                    }
                }
                tempfileIndex = ResetIndex();
                string NameAndExtension = System.IO.Path.GetFileName(path);
                string PathToPdfFile    = PdfFolder.ToUpper() + @"\" + NameAndExtension.Replace("SLDDRW", "PDF");

                //  string PathToPdfFile = path.Replace("SLDDRW", "PDF");
                MergePdf(PathToPdfFile); // Path to temp file
                return(PathToPdfFile);
            }
            catch (System.Exception exception)
            {
                throw new System.Exception("Filed buld pdf file. " + exception.ToString());
            }
        }
Ejemplo n.º 7
0
 internal SwDrawing(IDrawingDoc drawing, ISldWorks app, ILogger logger)
     : base((IModelDoc2)drawing, app, logger)
 {
     Drawing = drawing;
 }
Ejemplo n.º 8
0
        private static void InsertBomTable(IList <BomData> bomDataList, IDrawingDoc swDrawing, string sheetName, string templateSheet)
        {
            var existSheet   = swDrawing.NewSheet3(sheetName, 9, 12, 1, 10, true, templateSheet, 0.21, 0.297, "По умолчанию");
            var nawSheetName = sheetName;

            if (!existSheet)
            {
m1:
                var newNumber = Convert.ToInt32(nawSheetName.Replace(nawSheetName.Remove(2), "")) + 1;
                nawSheetName  = sheetName.Remove(2) + newNumber;
                var exist = swDrawing.NewSheet3(nawSheetName, 9, 12, 1, 10, true, templateSheet, 0.21, 0.297, "По умолчанию");
                if (!exist)
                {
                    goto m1;
                }
            }

            swDrawing.ActivateSheet(nawSheetName);

            var myTable = swDrawing.InsertTableAnnotation(0.02, 0.292, 1, bomDataList.Count + 1, 7);

            if ((myTable == null))
            {
                return;
            }
            for (var i = 0; i < BomSettings.КоличествоСтрокНаПервомЛистеА4; i++)
            {
                myTable.SetRowHeight(i, 0.008, 0);
            }
            myTable.Title            = "Таблица видов";
            myTable.BorderLineWeight = 1;
            myTable.GridLineWeight   = 1;

            #region Ширина колонок

            myTable.SetRowHeight(0, 0.015, 0);
            myTable.SetColumnWidth(0, 0.006, 0);
            myTable.SetColumnWidth(1, 0.006, 0);
            myTable.SetColumnWidth(2, 0.008, 0);
            myTable.SetColumnWidth(3, 0.07, 0);
            myTable.SetColumnWidth(4, 0.063, 0);
            myTable.SetColumnWidth(5, 0.010, 0);
            myTable.SetColumnWidth(6, 0.022, 0);

            #endregion

            const int position = 1;

            for (var i = 0; i < bomDataList.Count(); i++)
            {
                myTable.Text[position + i, 0] = bomDataList[i].Формат;
                myTable.Text[position + i, 2] = bomDataList[i].Row;
                myTable.Text[position + i, 3] = bomDataList[i].Обозначение;
                myTable.Text[position + i, 4] = bomDataList[i].Наименование;
                myTable.Text[position + i, 5] = bomDataList[i].Количество;
                myTable.Text[position + i, 6] = bomDataList[i].Примечание;
                var наименование = bomDataList[i].Наименование;
                if (наименование == null)
                {
                    myTable.SetRowHeight(position + i, 0.008, 0);
                }
                else
                {
                    myTable.SetRowHeight(position + i, наименование.Count() < 35 ? 0.008 : 0.016, 0);
                }

                if (i <= position)
                {
                    continue;
                }
                myTable.set_CellTextHorizontalJustification(position + i, 0,
                                                            (int)swTextJustification_e.swTextJustificationRight);
            }
        }