Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DrawingHandler drawingHandler = new DrawingHandler();
            Drawing        drawing        = drawingHandler.GetActiveDrawing();

            if (drawing == null)
            {
                int number = int.Parse(textBox1.Text);
                for (int i = 1; i <= number; i++)
                {
                    Tekla.Structures.Drawing.Size    size         = new Tekla.Structures.Drawing.Size(410, 287);
                    Tekla.Structures.Drawing.Drawing newGADrawing = new GADrawing("standard", size);
                    newGADrawing.Insert();
                }
            }
            else
            {
                MessageBox.Show("Close active drawing first");
            }
        }
Example #2
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            try
            {
                TSM.Model          model          = new TSM.Model();
                TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();
                TSG.Vector         UpDirection    = new TSG.Vector(0.0, 0.0, 1.0);
                TSD.Size           A3             = new TSD.Size(410, 287);

                TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());

                TSM.ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects();
                while (modelObjectEnum.MoveNext())
                {
                    if (modelObjectEnum.Current is Tekla.Structures.Model.Part)
                    {
                        TSM.Part selectedPart = (TSM.Part)modelObjectEnum.Current;

                        string USER_FIELD_3 = "", USER_FIELD_4 = "";
                        selectedPart.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3);
                        selectedPart.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4);
                        USER_FIELD_4 = USER_FIELD_4.Replace("(?)", "");
                        selectedPart.SetUserProperty("USER_FIELD_4", USER_FIELD_4);

                        if (USER_FIELD_3 == "M")
                        {
                            TSD.Drawing gaDrawing = new TSD.GADrawing("BRAD-Mod-Ass", A3);
                            gaDrawing.Name   = selectedPart.Name;
                            gaDrawing.Title1 = "SITEWORK";
                            gaDrawing.Title2 = USER_FIELD_3 + USER_FIELD_4;
                            gaDrawing.Title3 = "";
                            gaDrawing.Insert();
                            drawingHandler.SetActiveDrawing(gaDrawing, false);

                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane(selectedPart.GetCoordinateSystem()));
                            TSM.Solid tsolid  = selectedPart.GetSolid();
                            TSG.Point tsMinPt = tsolid.MinimumPoint;
                            TSG.Point tsMaxPt = tsolid.MaximumPoint;
                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane());

                            if (selectedPart.Name.Contains("BEAM"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX) * -1.0;
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                PlanViewCoordSys.AxisX = tempVector.Cross(UpDirection);
                                PlanViewCoordSys.AxisY = tempVector;

                                TSM.Solid solid = selectedPart.GetSolid();

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisX = tempVector.Cross(UpDirection).GetNormal();
                                FrontViewCoordSys.AxisY = UpDirection.GetNormal();

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 2));
                                FrontView.Modify();
                            }
                            if (selectedPart.Name.Contains("COLUMN"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX);
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY).Cross(UpDirection) * -1;

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 30));
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Modify();
                            }
                            drawingHandler.CloseActiveDrawing(true);
                        }
                    }
                }
                MessageBox.Show("Drawings Created");
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
            }
            catch { }
        }
Example #3
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); }
        }
Example #4
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 { }
        }
Example #5
0
        private void TeklaForm_Load(object sender, EventArgs e)
        {
            printerSettingsPath = model.GetInfo().ModelPath + @"\PrintSettings.ini";
            System.IO.FileInfo printerSettingsFile = new System.IO.FileInfo(printerSettingsPath);
            if (!printerSettingsFile.Exists)
            {
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(printerSettingsPath))
                {
                    sw.WriteLine("printer=PDF:1");
                    sw.WriteLine("printer=copier:Auto");
                    sw.WriteLine("printer=epson:Auto");
                    sw.WriteLine("printsize=Auto:0,0");
                    sw.WriteLine("printsize=A3:410,287");
                    sw.WriteLine("printsize=A4:280,195");
                    sw.WriteLine("papersize=A0:1152,825:A3:0.35");
                    sw.WriteLine("papersize=A1:825,560:A3:0.49");
                    sw.WriteLine("papersize=A2:580,405:A4:0.49");
                    sw.WriteLine("papersize=A3:405,280:A4:0.70");
                    sw.WriteLine("papersize=A4:280,195:A4:1.00");
                    sw.WriteLine(@"plotfiledirectory=C:\pdf-plots\");
                }
                System.Diagnostics.Process.Start(printerSettingsPath);
                MessageBox.Show("Modify settings if necessary and\nrestart to load settings");
                Application.Exit();
            }
            else
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(printerSettingsPath))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] propertyLine  = line.Split(new char[] { '=' });
                        string   propertyName  = propertyLine[0];
                        string   propertyValue = propertyLine[1];
                        if (propertyName == "printer")
                        {
                            string[] printerSettings = propertyValue.Split(new char[] { ':' });
                            string   printerName     = printerSettings[0];
                            string   printerScale    = printerSettings[1];
                            printerNames.Add(printerName);
                            printerScales.Add(printerScale);
                            cmbPrinter.Items.Add(printerName);
                        }

                        if (propertyName == "printsize")
                        {
                            string[] printsizeProperties  = propertyValue.Split(new char[] { ':' });
                            string   printsizeName        = printsizeProperties[0];
                            string[] printsizeWidthHeight = printsizeProperties[1].Split(new char[] { ',' });
                            double   printsizeWidth       = double.Parse(printsizeWidthHeight[0]);
                            double   printsizeHeight      = double.Parse(printsizeWidthHeight[1]);
                            Tekla.Structures.Drawing.Size printsizeDimension = new Tekla.Structures.Drawing.Size(printsizeWidth, printsizeHeight);
                            printsizeNames.Add(printsizeName);
                            printsizeDimensions.Add(printsizeDimension);
                            cmbSize.Items.Add(printsizeName);
                        }

                        if (propertyName == "papersize")
                        {
                            string[] papersizeProperties  = propertyValue.Split(new char[] { ':' });
                            string   papersizeName        = papersizeProperties[0];
                            string[] papersizeWidthHeight = papersizeProperties[1].Split(new char[] { ',' });
                            double   papersizeWidth       = double.Parse(papersizeWidthHeight[0]);
                            double   papersizeHeight      = double.Parse(papersizeWidthHeight[1]);
                            Tekla.Structures.Drawing.Size papersizeDimension = new Tekla.Structures.Drawing.Size(papersizeWidth, papersizeHeight);
                            string papersizeAutoPrintsizeName = papersizeProperties[2];
                            double papersizeAutoScale         = double.Parse(papersizeProperties[3]);
                            papersizeNames.Add(papersizeName);
                            papersizeDimensions.Add(papersizeDimension);
                            papersizeAutoPrintsizeNames.Add(papersizeAutoPrintsizeName);
                            papersizeAutoScales.Add(papersizeAutoScale);
                        }
                        if (propertyName == "plotfiledirectory")
                        {
                            plotfileDirectory = propertyValue;
                        }
                    }
                }
            }
        }