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 void btnShow_Click(object sender, EventArgs e)
        {
            lblMessage.Text = "";

            DrawingHandler MyDrawingHandler = new DrawingHandler();
            int            nDrawings        = 0;

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                int iCounter = 0;
                while (SelectedDrawings.MoveNext())
                {
                    iCounter++;
                }
                nDrawings = iCounter;
            }

            progressBar1.Minimum = 0;
            progressBar1.Maximum = nDrawings;
            progressBar1.Step    = 1;

            if (MyDrawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator SelectedDrawings = MyDrawingHandler.GetDrawingSelector().GetSelected();
                int iCounter = 1;
                while (SelectedDrawings.MoveNext())
                {
                    progressBar1.PerformStep();

                    Drawing      currentDrawing = SelectedDrawings.Current;
                    ListViewItem currentRow     = new ListViewItem(currentDrawing.Mark);

                    currentRow.SubItems.Add(currentDrawing.Name);
                    string strHeight = currentDrawing.Layout.SheetSize.Height.ToString();
                    string strWidth  = currentDrawing.Layout.SheetSize.Width.ToString();
                    currentRow.SubItems.Add(strWidth + "x" + strHeight);
                    string PrinterInstance = "QP_" + strWidth + "x" + strHeight;

                    //TSM.Operations.Operation.DisplayPrompt("Drawing " + currentDrawing.Name + ": " + iCounter.ToString() + "/" + nDrawings.ToString());
                    lblMessage.Text = "";
                    lblMessage.Text = "Drawing " + currentDrawing.Name + ": " + iCounter.ToString() + "/" + nDrawings.ToString();
                    iCounter++;

                    if (chkPDF.Checked)
                    {
                        WriteCurrentDrawing(currentDrawing, PrinterInstance);
                    }

                    if (chkDWG.Checked)
                    {
                        PrintToFile(currentDrawing);
                    }
                }
            }

            //TSM.Operations.Operation.DisplayPrompt("Write command completed!");
            lblMessage.Text    = "Write command completed!";
            progressBar1.Value = 0;
        }
Exemple #3
0
        private static DrawingEnumerator getSelectedDrawings()
        {
            DrawingHandler    myDrawingHandler = new DrawingHandler();
            DrawingEnumerator selectedDrawings = myDrawingHandler.GetDrawingSelector().GetSelected();

            return(selectedDrawings);
        }
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            Model             model              = new Model();
            ModelInfo         modelInfo          = model.GetInfo();
            string            drawingsFolderPath = modelInfo.ModelPath + @"\drawings\";
            DrawingHandler    drawingHandler     = new DrawingHandler();
            DrawingEnumerator drawingEnum        = drawingHandler.GetDrawingSelector().GetSelected();

            if (drawingEnum.GetSize() == 1)
            {
                while (drawingEnum.MoveNext())
                {
                    System.Reflection.PropertyInfo propertyInfo = drawingEnum.Current.GetType().GetProperty("Identifier", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                    object value = propertyInfo.GetValue(drawingEnum.Current, null);

                    Identifier Identifier = (Identifier)value;
                    Beam       tempBeam   = new Beam();
                    tempBeam.Identifier = Identifier;

                    string             drawingFile = "";
                    bool               result      = tempBeam.GetReportProperty("DRAWING_PLOT_FILE", ref drawingFile);
                    System.IO.FileInfo file        = new System.IO.FileInfo(drawingsFolderPath + drawingFile);
                    if (file.Exists)
                    {
                        System.Diagnostics.Process.Start("Explorer.exe", @"/select, " + file.FullName);
                    }
                }
            }
        }
Exemple #5
0
 public static dynamic GetTSObject(DrawingEnumerator dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
        public void ReturnFullNameToTextFile()
        {
            string path     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string document = "drawings.csv";

            DrawingHandler drawingHandler = new DrawingHandler();

            DrawingEnumerator selectedDrawings = drawingHandler.GetDrawingSelector().GetSelected();

            string result = string.Empty;

            string title1        = string.Empty;
            string title2        = string.Empty;
            string number        = string.Empty;
            string projectNumber = string.Empty;
            string drType        = string.Empty;

            while (selectedDrawings.MoveNext())
            {
                var currentDrawingInfo = new DrawingInfo();

                Drawing drawing = selectedDrawings.Current;

                currentDrawingInfo.BaseName = drawing.GetType() + drawing.Mark;

                currentDrawingInfo.DrawingName = drawing.Name;

                drawing.GetUserProperty("PM_DRAWING_TITLE_1", ref title1);
                drawing.GetUserProperty("PM_DRAWING_TITLE_2", ref title2);
                drawing.GetUserProperty("PM_DRAWING_TYPE", ref drType);
                drawing.GetUserProperty("Nr_dokumentu", ref number);
                drawing.GetUserProperty("Nr_projektu", ref projectNumber);

                currentDrawingInfo.DrawingTitle1         = title1;
                currentDrawingInfo.DrawingTitle2         = title2;
                currentDrawingInfo.DrawingType           = drType;
                currentDrawingInfo.DrawingTitle2Expanded = this.ReturnFullTitle(title2);
                currentDrawingInfo.DrawingProjectNumber  = projectNumber;
                currentDrawingInfo.DrawingNumber         = number;

                result += currentDrawingInfo.ToString() + "\n";
            }

            var lines = result.Split('\n');

            using (StreamWriter outputFile = new StreamWriter(path + @"\" + document))
            {
                foreach (string line in lines)
                {
                    outputFile.WriteLine(line);
                }
            }

            MessageBox.Show("All done!");
        }
Exemple #7
0
        private void SelectedDrawing_Click(object sender, EventArgs e)
        {
            this.progressBar1.Value = 0;
            DrawingHandler drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                DrawingEnumerator selected = drawingHandler.GetDrawingSelector().GetSelected();
                this.RenameDrawingTitle(selected);
            }
        }
        /// <summary>Add items from the enumerator to the System.Collections.Generic.List</summary>
        public static List <Drawing> ToList(this DrawingEnumerator enumerator)
        {
            var output = new List <Drawing>(enumerator.GetSize());

            while (enumerator.MoveNext())
            {
                output.Add(enumerator.Current);
            }

            return(output);
        }
Exemple #9
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            string fileName = @"Reports/test.csv";

            try
            {
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
            }
            catch { }

            int               drawingNr        = 1;
            DrawingHandler    myDrawingHandler = new DrawingHandler();
            DrawingEnumerator selectedDrawings = myDrawingHandler.GetDrawingSelector().GetSelected();

            var csv = new StringBuilder();

            foreach (Drawing currentDrawing in selectedDrawings)
            {
                string name = currentDrawing.Title1;
                string nr   = currentDrawing.Name;

                DateTime dmtDate        = new DateTime(1970, 1, 1);
                int      dmtDateSeconds = 0;
                currentDrawing.GetUserProperty("DR_RESP_DSGNR_DATE", ref dmtDateSeconds);
                dmtDate = dmtDate.AddSeconds(dmtDateSeconds);

                DateTime revisionDate        = new DateTime(1970, 1, 1);
                int      revisionDateSeconds = 0;
                string   revisionMark        = "";
                DateLastMark(currentDrawing, out revisionMark, out revisionDateSeconds);
                revisionDate = revisionDate.AddSeconds(revisionDateSeconds);

                string newLine = string.Format("{0} ;{1} ;{2} ;{3} ;{4} ;", name, nr, revisionMark, dmtDate.ToShortDateString(), revisionDate.ToShortDateString());
                csv.AppendLine(newLine);

                //MessageBox.Show(newLine);

                drawingNr++;
            }

            try
            {
                File.WriteAllText(fileName, csv.ToString());
            }
            catch
            {
                MessageBox.Show("write failed");
            }
        }
Exemple #10
0
        public static void main()
        {
            DrawingEnumerator selectedDrawings = getSelectedDrawings();

            foreach (Drawing currentDrawing in selectedDrawings)
            {
                double highestScale = getHighestScale(currentDrawing);
                setScaleToTitle3(currentDrawing, highestScale);
            }

            MessageBox.Show("Valitud " + selectedDrawings.GetSize() + " joonist." + Environment.NewLine +
                            "Muudetud " + selectedDrawings.GetSize() + " joonise title3");
        }
        /// <summary>Add items from the enumerator to the System.Collections.Generic.List. if (enumerator.Current is T t) output.Add(t);</summary>
        public static List <T> ToList <T>(this DrawingEnumerator enumerator) where T : Drawing
        {
            var output = new List <T>(enumerator.GetSize());

            while (enumerator.MoveNext())
            {
                if (enumerator.Current is T t)
                {
                    output.Add(t);
                }
            }

            return(output);
        }
        private ArrayList getSelectedCastUnitDrawing(DrawingEnumerator selectedDrawings)
        {
            ArrayList selectedCastUnitDrawings = new ArrayList();

            while (selectedDrawings.MoveNext())
            {
                if (selectedDrawings.Current is CastUnitDrawing)
                {
                    selectedCastUnitDrawings.Add(selectedDrawings.Current);
                }
            }

            return(selectedCastUnitDrawings);
        }
        private ArrayList getSelectedCastUnitDrawing(DrawingEnumerator selectedDrawings)
        {
            ArrayList selectedCastUnitDrawings = new ArrayList();

            while (selectedDrawings.MoveNext())
            {
                if (selectedDrawings.Current is CastUnitDrawing)
                {
                    selectedCastUnitDrawings.Add(selectedDrawings.Current);
                }
            }

            return selectedCastUnitDrawings;
        }
        private void PickExtraSheets_Click(object sender, EventArgs e)
        {
            ExtraSheets.Clear();
            ExtraSheetsList.Items.Clear();
            bool      error             = false;
            Model     model             = new Model();
            ModelInfo modelInfo         = model.GetInfo();
            string    drawingFolderPath = modelInfo.ModelPath + @"\drawings\";

            DrawingHandler    drawingHandler = new DrawingHandler();
            DrawingEnumerator drawingEnum    = drawingHandler.GetDrawingSelector().GetSelected();

            if (drawingEnum.GetSize() > 0)
            {
                while (drawingEnum.MoveNext())
                {
                    if (drawingEnum.Current is AssemblyDrawing)
                    {
                        PropertyInfo pi         = drawingEnum.Current.GetType().GetProperty("Identifier", BindingFlags.Instance | BindingFlags.NonPublic);
                        object       value      = pi.GetValue(drawingEnum.Current, null);
                        Identifier   Identifier = (Identifier)value;
                        Beam         temporary  = new Beam();
                        temporary.Identifier = Identifier;

                        string dgFileName = "";
                        bool   dg         = temporary.GetReportProperty("DRAWING_PLOT_FILE", ref dgFileName);

                        FileInfo dgFile = new FileInfo(drawingFolderPath + dgFileName);
                        if (dgFile.Exists)
                        {
                            ExtraSheets.Add(dgFile.FullName);
                            ExtraSheetsList.Items.Add(drawingEnum.Current.Mark);
                        }
                    }
                    else
                    {
                        error = true;
                    }
                }
                CopyViews.Enabled = true;
                if (error == true)
                {
                    MessageBox.Show("Pick Assembly Drawings Only");
                    ExtraSheets.Clear();
                    ExtraSheetsList.Items.Clear();
                    CopyViews.Enabled = false;
                }
            }
        }
        public void main()
        {
            DrawingEnumerator selectedDrawings         = getSelectedDrawings();
            ArrayList         selectedCastUnitDrawings = getSelectedCastUnitDrawing(selectedDrawings);

            foreach (CastUnitDrawing currentDrawing in selectedCastUnitDrawings)
            {
                string objectName = getObjectName(currentDrawing);
                changeDrawingName(currentDrawing, objectName);
            }

            _myModel.CommitChanges();

            MessageBox.Show("Valitud " + selectedDrawings.GetSize() + " joonist." + Environment.NewLine +
                            "Muudetud " + selectedCastUnitDrawings.Count.ToString() + " joonise nime");
        }
Exemple #16
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            Model             model          = new Model();
            DrawingHandler    drawingHandler = new DrawingHandler();
            DrawingEnumerator drawingEnum    = drawingHandler.GetDrawingSelector().GetSelected();

            if (drawingHandler.GetActiveDrawing() == null)
            {
                while (drawingEnum.MoveNext())
                {
                    if (drawingEnum.Current is AssemblyDrawing)
                    {
                        AssemblyDrawing assemblyDrawing = drawingEnum.Current as AssemblyDrawing;
                        drawingHandler.SetActiveDrawing(assemblyDrawing, false);
                        DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetActiveDrawing().GetSheet().GetAllObjects();
                        while (drawingObjectEnum.MoveNext())
                        {
                            if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Part)
                            {
                                Tekla.Structures.Drawing.Part part = drawingObjectEnum.Current as Tekla.Structures.Drawing.Part;
                                ArrayList array = new ArrayList();
                                array.Add(model.SelectModelObject(new Tekla.Structures.Identifier(part.ModelIdentifier.ID)));
                                Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector();
                                modelObjectSelector.Select(array);
                                ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects();
                                while (modelObjectEnum.MoveNext())
                                {
                                    if (modelObjectEnum.Current is Tekla.Structures.Model.Part)
                                    {
                                        Tekla.Structures.Model.Part     mpart    = modelObjectEnum.Current as Tekla.Structures.Model.Part;
                                        Tekla.Structures.Model.Assembly assembly = mpart.GetAssembly();
                                        Tekla.Structures.Model.Part     mainPart = (Tekla.Structures.Model.Part)assembly.GetMainPart();
                                        assemblyDrawing.Name = mainPart.Name;
                                        assemblyDrawing.Modify();
                                        assemblyDrawing.CommitChanges();
                                    }
                                }
                                modelObjectSelector.Select(new ArrayList());
                            }
                        }
                        drawingHandler.CloseActiveDrawing();
                    }
                }
            }
        }
        private void PickMainDrawing_Click(object sender, EventArgs e)
        {
            Model     model             = new Model();
            ModelInfo modelInfo         = model.GetInfo();
            string    drawingFolderPath = modelInfo.ModelPath + @"\drawings\";

            DrawingHandler    drawingHandler = new DrawingHandler();
            DrawingEnumerator drawingEnum    = drawingHandler.GetDrawingSelector().GetSelected();

            if (drawingEnum.GetSize() == 1)
            {
                while (drawingEnum.MoveNext())
                {
                    if (drawingEnum.Current is AssemblyDrawing)
                    {
                        PropertyInfo pi         = drawingEnum.Current.GetType().GetProperty("Identifier", BindingFlags.Instance | BindingFlags.NonPublic);
                        object       value      = pi.GetValue(drawingEnum.Current, null);
                        Identifier   Identifier = (Identifier)value;
                        Beam         temporary  = new Beam();
                        temporary.Identifier = Identifier;

                        string dgFileName = "";
                        bool   dg         = temporary.GetReportProperty("DRAWING_PLOT_FILE", ref dgFileName);

                        FileInfo dgFile = new FileInfo(drawingFolderPath + dgFileName);
                        if (dgFile.Exists)
                        {
                            MainDrawing            = dgFile.FullName;
                            MainDrawingNumber.Text = drawingEnum.Current.Mark;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Pick ONE Assembly Drawing");
                    }
                }
                CreateExtraSheets.Enabled = true;
            }
            else
            {
                MessageBox.Show("Pick ONE Assembly Drawing");
            }
        }
        public string GetMultiInfo()
        {
            string result = string.Empty;

            DrawingHandler drawingHandler = new DrawingHandler();

            DrawingEnumerator selectedDrawings = drawingHandler.GetDrawingSelector().GetSelected();

            List <DrawingInfo> listOfDrawings = new List <DrawingInfo>();

            string number        = string.Empty;
            string projectNumber = string.Empty;
            string title1        = string.Empty;
            string title2        = string.Empty;
            string name          = string.Empty;

            while (selectedDrawings.MoveNext())
            {
                var currentDrawingInfo = new DrawingInfo();

                Drawing drawing = selectedDrawings.Current;

                currentDrawingInfo.BaseName = drawing.GetType() + drawing.Mark;

                currentDrawingInfo.DrawingName = drawing.Name;

                drawing.GetUserProperty("PM_DRAWING_TITLE_1", ref title1);
                drawing.GetUserProperty("PM_DRAWING_TITLE_2", ref title2);
                drawing.GetUserProperty("Nr_dokumentu", ref number);
                drawing.GetUserProperty("Nr_projektu", ref projectNumber);

                currentDrawingInfo.DrawingTitle1         = title1;
                currentDrawingInfo.DrawingTitle2         = title2;
                currentDrawingInfo.DrawingTitle2Expanded = this.ReturnFullTitle(title2);
                currentDrawingInfo.DrawingProjectNumber  = projectNumber;
                currentDrawingInfo.DrawingNumber         = number;

                name = currentDrawingInfo.ToString();
            }

            return(name);
        }
        /// <summary>
        /// When application starts, this gets the drawings from Tekla Structures and adds them to the list
        /// </summary>
        private void AddDrawingsToListView()
        {
            if (MyDrawingHandler.GetConnectionStatus())
            {
                int Index = 0;
                DrawingEnumerator MyDrawingEnumerator = MyDrawingHandler.GetDrawings();

                while (MyDrawingEnumerator.MoveNext())
                {
                    Drawing      CurrentDrawing = MyDrawingEnumerator.Current;
                    ListViewItem Item           = new ListViewItem();

                    Item.Tag  = CurrentDrawing;
                    Item.Text = Index + " " + GetDrawingTypeCharacter(CurrentDrawing) + " - " + CurrentDrawing.Mark;

                    listView1.Items.Add(Item);
                    Index++;
                }
            }
        }
        public string ReturnFullName()
        {
            string result = string.Empty;

            DrawingHandler drawingHandler = new DrawingHandler();

            DrawingEnumerator selectedDrawings = drawingHandler.GetDrawingSelector().GetSelected();

            string title2 = string.Empty;

            while (selectedDrawings.MoveNext())
            {
                Drawing drawing = selectedDrawings.Current;

                drawing.GetUserProperty("PM_DRAWING_TITLE_2", ref title2);
            }

            title2 = title2.Remove(0, 4);

            result = this.ExpandTitle(title2);

            return(result);
        }
        private void CreateExtraSheets_Click(object sender, EventArgs e)
        {
            akit.Callback("acmd_display_attr_dialog", "adraw_dial", "main_frame"); // open drawing settings dialog
            akit.ValueChange("adraw_dial", "gr_adraw_get_menu", "KWP-blank");      // select blank attributes
            akit.PushButton("gr_adraw_get", "adraw_dial");                         // load attributes

            Model model = new Model();

            Tekla.Structures.Model.UI.ModelObjectSelector mObjSelector = new Tekla.Structures.Model.UI.ModelObjectSelector();
            DrawingHandler    drawingHandler = new DrawingHandler();
            DrawingEnumerator drawingEnum    = drawingHandler.GetDrawingSelector().GetSelected();

            if (drawingEnum.GetSize() > 0)
            {
                while (drawingEnum.MoveNext())
                {
                    if (drawingEnum.Current is AssemblyDrawing)
                    {
                        AssemblyDrawing assemblyDrawing = drawingEnum.Current as AssemblyDrawing;
                        akit.ValueChange("adraw_dial", "gr_adraw_description", assemblyDrawing.Name); // change name
                        akit.PushButton("dia_draw_select_parts", "Drawing_selection");                // select parts in drawing
                        int  count  = 0;
                        bool result = int.TryParse(RequiredSheets.Text, out count);
                        for (int i = 2; i <= count; i++)
                        {
                            akit.ValueChange("adraw_dial", "txtFldSheetNumber", i.ToString());    // change sheet number
                            akit.PushButton("gr_adraw_apply", "adraw_dial");                      // apply settings
                            akit.Callback("acmd_create_dim_assembly_drawings", "", "main_frame"); // create assembly drawing for selected part
                        }

                        mObjSelector.Select(new ArrayList());
                    }
                }
            }
            PickExtraSheets.Enabled = true;
        }
        public void WriteNumber(string file)
        {
            DrawingHandler drawingHandler = new DrawingHandler();

            DrawingEnumerator selectedDrawings = drawingHandler.GetDrawingSelector().GetSelected();

            FileInfo toRead = new FileInfo();

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary = toRead.ConvertFileToDictionary(file);

            while (selectedDrawings.MoveNext())
            {
                Drawing drawing = selectedDrawings.Current;

                string searchedNumber = drawing.GetType() + drawing.Mark;

                string result = toRead.ReturnNumberFromDictionary(searchedNumber, dictionary);

                drawing.SetUserProperty("Nr_dokumentu", result);
                drawing.CommitChanges();
            }
        }
Exemple #23
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); }
        }
Exemple #24
0
        public void GetData(Shared.Models.User user)
        {
            try
            {
                DrawingEnumerator SelectedDrawings = CourretDrawingHandler.GetDrawingSelector().GetSelected();

                logger.Info("Чертежи успешно получены");

                Drawings = new List <Shared.Models.Drawing>();

                Errors = new List <StringErrorBindingModel>();

                while (SelectedDrawings.MoveNext())
                {
                    try
                    {
                        if (SelectedDrawings.Current is AssemblyDrawing)
                        {
                            String Number = "";

                            Assembly assembly = model.SelectModelObject(((SelectedDrawings.Current as AssemblyDrawing)).AssemblyIdentifier) as Assembly;

                            if (!ChechedDate(assembly))
                            {
                                assembly.GetReportProperty("CUSTOM.Zakaz", ref Number);
                                Errors.Add(new StringErrorBindingModel {
                                    Data = $"Заказ: {Number}, Марка: {SelectedDrawings.Current.Mark}", Error = "Не заполнено поле \"Дата\""
                                });
                                continue;
                            }

                            GetDrawing(assembly, SelectedDrawings.Current as AssemblyDrawing);
                        }
                    }
                    catch (Exception E)
                    {
                        String   Number   = "";
                        String   List     = "";
                        Assembly assembly = model.SelectModelObject(((SelectedDrawings.Current as AssemblyDrawing)).AssemblyIdentifier) as Assembly;
                        assembly.GetReportProperty("CUSTOM.Zakaz", ref Number);
                        assembly.GetReportProperty("CUSTOM.Drw_SheetRev", ref List);
                        logger.Error(E.ToString());
                        Errors.Add(new StringErrorBindingModel {
                            Data = $"Заказ: {Number}, Лист: {List}", Error = E.Message
                        });
                    }
                }

                logger.Info("Чертежи добавлены");

                ModelInfo modelInfo = model.GetInfo();
                Model = new Shared.Models.Model {
                    DateCreate = DateTime.Now, Path = modelInfo.ModelPath, Drawings = Drawings
                };

                notify.Close();

                if (Errors.Count > 0)
                {
                    ReportErrors Report = new ReportErrors();
                    Report.Report_DGV.AutoGenerateColumns = false;
                    Report.Report_DGV.DataSource          = Errors;

                    Report.ShowDialog();
                }

                if (Model.Drawings.Count() > 0)
                {
                    logger.Info("Начат показ чертежей");

                    Operations operations = new Operations();
                    operations.ShowData(Model, user);
                }
            }
            catch (Exception E)
            {
                maillogger.SendErrorLog(E.ToString());
                logger.Error(E.ToString());
                MessageBox.Show("Ошибка операции", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #25
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(plotfileDirectory);
                if (dir.Exists)
                {
                    string datetime = DateTime.Now.ToString().Replace(':', '-').Replace('/', '-');
                    System.IO.DirectoryInfo datefolder = new System.IO.DirectoryInfo(plotfileDirectory + @"\" + datetime + @"\");
                    datefolder.Create();
                    System.Diagnostics.Process.Start(datefolder.FullName);
                    DrawingEnumerator drawingEnum = drawingHandler.GetDrawingSelector().GetSelected();
                    while (drawingEnum.MoveNext())
                    {
                        Drawing drawing = (Drawing)drawingEnum.Current;

                        System.Reflection.PropertyInfo propertyInfo = drawing.GetType().GetProperty("Identifier", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                        object value = propertyInfo.GetValue(drawing, null);

                        Identifier Identifier = (Identifier)value;
                        Beam       fakebeam   = new Beam();
                        fakebeam.Identifier = Identifier;
                        string RevisionMark = "";
                        bool   rev          = fakebeam.GetReportProperty("REVISION.LAST_MARK", ref RevisionMark);
                        string drawingMark  = "";
                        if (drawing is SinglePartDrawing || drawing is AssemblyDrawing)
                        {
                            drawingMark = drawing.Mark.Replace("[", "").Replace(".", "").Replace("]", "") + RevisionMark;
                        }
                        if (drawing is GADrawing)
                        {
                            if (RevisionMark.Length > 0)
                            {
                                RevisionMark = "-" + RevisionMark;
                            }
                            drawingMark = drawing.Title2 + RevisionMark;
                        }
                        System.IO.FileInfo file = new System.IO.FileInfo(dir.FullName + @"\" + drawingMark + ".pdf");
                        if (file.Exists)
                        {
                            if (drawing is SinglePartDrawing)
                            {
                                System.IO.DirectoryInfo singlePartDrawingFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\FIT\");
                                singlePartDrawingFolder.Create();
                                file.MoveTo(singlePartDrawingFolder.FullName + file.Name);
                            }
                            if (drawing is AssemblyDrawing)
                            {
                                System.IO.DirectoryInfo assemblyDrawingFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\ASS\");
                                assemblyDrawingFolder.Create();

                                for (int i = 0; i < papersizeNames.Count; i++)
                                {
                                    Tekla.Structures.Drawing.Size m = (Tekla.Structures.Drawing.Size)papersizeDimensions[i];
                                    if (drawing.Layout.SheetSize.Height == m.Height && drawing.Layout.SheetSize.Width == m.Width)
                                    {
                                        System.IO.DirectoryInfo assemblyDrawingSizeFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\ASS\" + papersizeNames[i].ToString() + @"\");
                                        assemblyDrawingSizeFolder.Create();
                                        file.MoveTo(assemblyDrawingSizeFolder.FullName + file.Name);
                                    }
                                }
                            }
                            if (drawing is GADrawing)
                            {
                                System.IO.DirectoryInfo gaDrawingFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\GAS\");
                                gaDrawingFolder.Create();
                                file.MoveTo(gaDrawingFolder.FullName + file.Name);
                            }
                        }
                    }
                }
            }
            catch { }
        }
Exemple #26
0
        private void RenameDrawingTitle(DrawingEnumerator DrawingList)
        {
            this.progressBar1.Maximum = DrawingList.GetSize();
            int  num           = 1;
            int  num2          = 0;
            int  num3          = 0;
            int  num4          = 0;
            bool needsUpdating = false;

            while (DrawingList.MoveNext())
            {
                this.progressBar1.Value++;
                this.CurrentNo.Text = num++.ToString() + '/' + DrawingList.GetSize().ToString();
                this.CurrentNo.Refresh();

                string mainpartname        = "";
                string existingDrawingname = "";    // Name of the drawing before modify

                Tekla.Structures.Model.ModelObject modelObject = null;

                Drawing currentDrawing = DrawingList.Current;
                if (currentDrawing.UpToDateStatus.ToString() != "DrawingIsUpToDate")
                {
                    needsUpdating = true;
                    continue;
                }

                if (DrawingList.Current is AssemblyDrawing)
                {
                    AssemblyDrawing assemblyDrawing    = DrawingList.Current as AssemblyDrawing;
                    Identifier      assemblyIdentifier = assemblyDrawing.AssemblyIdentifier;
                    modelObject = this.My_model.SelectModelObject(assemblyIdentifier);

                    modelObject.GetReportProperty("ASSEMBLY_NAME", ref mainpartname);

                    num2++;
                }

                if (DrawingList.Current is SinglePartDrawing)
                {
                    SinglePartDrawing singlePartDrawing = DrawingList.Current as SinglePartDrawing;
                    Identifier        partIdentifier    = singlePartDrawing.PartIdentifier;
                    modelObject = this.My_model.SelectModelObject(partIdentifier);

                    modelObject.GetReportProperty("NAME", ref mainpartname);
                }
                if (modelObject != null)
                {
                    // Check if drawing name already contains the automatic drawing name:
                    existingDrawingname = DrawingList.Current.Name;
                    bool drawingNameMatch = existingDrawingname.Contains(mainpartname);

                    if ((drawingNameMatch == true) || (drawingNameMatch = existingDrawingname.Contains("DS")))
                    {
                        num4++;
                    }
                    if (drawingNameMatch == false)
                    {
                        DrawingList.Current.Name = mainpartname;
                        DrawingList.Current.Modify();
                        num3++;
                    }
                }
            }

            if (needsUpdating == true)
            {
                MessageBox.Show("Some of the drawings are not up to date!\n\nNames were not updated for that drawings.", Variables.title);
            }

            MessageBox.Show(string.Concat(new object[]
            {
                num3,
                " Drawing's name changed \n",
                num4,
                " Drawings kept the existing name"
            }), Variables.title);
        }
Exemple #27
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            DrawingHandler    DrawingHandler = new DrawingHandler();
            DrawingEnumerator DrawingEnum    = DrawingHandler.GetDrawingSelector().GetSelected();

            if (DrawingEnum.GetSize() == 0)
            {
                // No drawings selected
                MessageBox.Show("No Drawings Selected");
                return;
            }

            while (DrawingEnum.MoveNext())
            {
                Drawing Drawing = DrawingEnum.Current;
                DrawingHandler.SetActiveDrawing(Drawing, false);
                DrawingObjectEnumerator DrawingObjEnum = Drawing.GetSheet().GetAllObjects();
                ArrayList MarkArray = new ArrayList();
                ArrayList PartArray = new ArrayList();
                while (DrawingObjEnum.MoveNext())
                {
                    if (DrawingObjEnum.Current is MarkBase)
                    {
                        MarkArray.Add(DrawingObjEnum.Current);
                    }

                    if (DrawingObjEnum.Current is Tekla.Structures.Drawing.Part || DrawingObjEnum.Current is Tekla.Structures.Drawing.Bolt)
                    {
                        PartArray.Add(DrawingObjEnum.Current);
                    }
                }
                DrawingHandler.GetDrawingObjectSelector().SelectObjects(MarkArray, true);

                // part mark properties
                akit.Callback("acmd_display_selected_drawing_object_dialog", "", "main_frame");
                akit.TabChange("pmark_dial", "Container_2", "gr_mark_general_tab");
                akit.PushButton("gr_pmark_place", "pmark_dial");
                akit.ValueChange("pmpl_dial", "text_placing_mode", "1");
                akit.PushButton("txpl_modify", "pmpl_dial");
                akit.PushButton("txpl_cancel", "pmpl_dial");
                akit.PushButton("pmark_cancel", "pmark_dial");

                // bolt mark properties
                akit.Callback("acmd_display_attr_dialog", "smark_dial", "main_frame");
                akit.TabChange("smark_dial", "Container_217", "gr_mark_general_tab");
                akit.PushButton("gr_smark_place", "smark_dial");
                akit.ValueChange("smpl_dial", "text_placing_mode", "1");
                akit.PushButton("txpl_modify", "smpl_dial");
                akit.PushButton("txpl_cancel", "smpl_dial");
                akit.PushButton("smark_cancel", "smark_dial");

                // connection mark properties
                akit.Callback("acmd_display_attr_dialog", "jmark_dial", "main_frame");
                akit.TabChange("jmark_dial", "Container_217", "gr_mark_general_tab");
                akit.PushButton("gr_jmark_place", "jmark_dial");
                akit.ValueChange("jmpl_dial", "text_placing_mode", "1");
                akit.PushButton("txpl_modify", "jmpl_dial");
                akit.PushButton("txpl_cancel", "jmpl_dial");
                akit.PushButton("jmark_cancel", "jmark_dial");

                DrawingHandler.GetDrawingObjectSelector().UnselectAllObjects();
                DrawingHandler.GetDrawingObjectSelector().SelectObjects(PartArray, true);
                akit.Callback("acmd_update_marks_selected", "", "main_frame");

                DrawingHandler.SaveActiveDrawing();
                DrawingHandler.CloseActiveDrawing();
            }
        }
        public void GetData(Shared.Models.User user)
        {
            try
            {
                DrawingEnumerator SelectedDrawings = CourretDrawingHandler.GetDrawingSelector().GetSelected();

                logger.Info("Чертежи успешно получены");

                Drawings = new List <Shared.Models.Drawing>();

                DrawingErrors   = new List <StringErrorBindingModel>();
                DetailsErrors   = new List <StringErrorBindingModel>();
                DetailsWarnings = new List <StringErrorBindingModel>();

                while (SelectedDrawings.MoveNext())
                {
                    try
                    {
                        if (SelectedDrawings.Current is AssemblyDrawing)
                        {
                            Assembly assembly = model.SelectModelObject(((SelectedDrawings.Current as AssemblyDrawing)).AssemblyIdentifier) as Assembly;

                            if (!ChechedDate(assembly))
                            {
                                throw new Exception("Не заполнено поле \"Дата\"");
                            }

                            GetDrawing(assembly, SelectedDrawings.Current as AssemblyDrawing);
                        }
                    }
                    catch (Exception E)
                    {
                        String   Number   = "";
                        String   List     = "";
                        Assembly assembly = model.SelectModelObject(((SelectedDrawings.Current as AssemblyDrawing)).AssemblyIdentifier) as Assembly;
                        assembly.GetReportProperty("CUSTOM.Zakaz", ref Number);
                        assembly.GetReportProperty("CUSTOM.Drw_SheetRev", ref List);
                        logger.Error(E.ToString());
                        DrawingErrors.Add(new StringErrorBindingModel {
                            Order = Number, List = List, Error = E.Message
                        });
                    }
                }

                logger.Info("Чертежи добавлены");

                ModelInfo modelInfo = model.GetInfo();
                string    ModelPath = modelInfo.ModelPath;

                if (ModelPath.Substring(0, 2) != @"\\")
                {
                    using (var managementObject = new ManagementObject())
                    {
                        managementObject.Path = new ManagementPath($"Win32_LogicalDisk='{ModelPath.Substring(0, 2)}'");
                        var driveType   = (DriveType)(uint)managementObject["DriveType"];
                        var networkPath = Convert.ToString(managementObject["ProviderName"]);

                        ModelPath = networkPath + ModelPath.Remove(0, 2);
                    }
                }

                ModelPath = ModelPath.Replace("tekla-fs", "10.0.7.249");

                Model = new Shared.Models.Model {
                    DateCreate = DateTime.Now, Path = ModelPath, Drawings = Drawings
                };


                notify.Close();

                if (DetailsWarnings.Count > 0)
                {
                    ReportWarnings Report = new ReportWarnings();
                    Report.Report_DGV.AutoGenerateColumns = false;
                    Report.Report_DGV.DataSource          = DetailsWarnings;

                    if (Report.ShowDialog() != DialogResult.OK)
                    {
                        for (int i = 0; i < DetailsWarnings.Count; i++)
                        {
                            Drawings.RemoveAll(p => p.Order == DetailsWarnings[i].Order && p.List == DetailsWarnings[i].List);
                        }
                    }
                }

                if (DetailsErrors.Count > 0)
                {
                    ReportErrors Report = new ReportErrors();
                    Report.Text        = "Отчет об ошибках деталей";
                    Report.label1.Text = "Отчет об ошибках деталей";
                    Report.Report_DGV.AutoGenerateColumns = false;
                    Report.Report_DGV.DataSource          = DetailsErrors;

                    Report.ShowDialog();
                }

                if (DrawingErrors.Count > 0)
                {
                    ReportErrors Report = new ReportErrors();
                    Report.Text        = "Отчет об ошибках чертежей";
                    Report.label1.Text = "Отчет об ошибках чертежей";
                    Report.Report_DGV.AutoGenerateColumns = false;
                    Report.Report_DGV.DataSource          = DrawingErrors;

                    Report.ShowDialog();
                }

                if (Model.Drawings.Count() > 0)
                {
                    logger.Info("Начат показ чертежей");

                    Operations operations = new Operations();
                    operations.ShowData(Model, user);
                }
            }
            catch (Exception E)
            {
                maillogger.SendErrorLog(E.ToString());
                logger.Error(E.ToString());
                MessageBox.Show("Ошибка операции", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }