示例#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");
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            TransformationPlane current = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); //Глобальная плоскость

            try
            {
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
                ModelObjectEnumerator selectedModelObjects = new Tekla.Structures.Model.UI.ModelObjectSelector().GetSelectedObjects();

                GADrawing MyDrawing = null;
                while (selectedModelObjects.MoveNext())
                {
                    Tekla.Structures.Geometry3d.CoordinateSystem ModelObjectCoordSys;
                    string ModelObjectName;

                    GetCoordinateSystemAndNameOfSelectedObject(selectedModelObjects, out ModelObjectCoordSys, out ModelObjectName);

                    //создание нового общего чертежа
                    string DrawingName = "PartBasicViews" + (selectedModelObjects.Current as Tekla.Structures.Model.ModelObject).Identifier;
                    MyDrawing = new GADrawing(DrawingName, "standard");
                    MyDrawing.Insert();

                    if (openDrawings.Checked)
                    {
                        DrawingHandler.SetActiveDrawing(MyDrawing, true); //Открытие чертежа в редакторе
                    }
                    else
                    {
                        DrawingHandler.SetActiveDrawing(MyDrawing, false); //Открытие чертежа в невидимом режиме
                    }
                    ArrayList Parts = new ArrayList();

                    if (selectedModelObjects.Current is Tekla.Structures.Model.Part)
                    {
                        Parts.Add(selectedModelObjects.Current.Identifier);
                    }
                    else if (selectedModelObjects.Current is Tekla.Structures.Model.Assembly)
                    {
                        Parts = GetAssemblyParts(selectedModelObjects.Current as Tekla.Structures.Model.Assembly);
                    }
                    else if (selectedModelObjects.Current is Tekla.Structures.Model.BaseComponent)
                    {
                        Parts = GetComponentParts(selectedModelObjects.Current as Tekla.Structures.Model.BaseComponent);
                    }

                    CreateViews(ModelObjectCoordSys, ModelObjectName, MyDrawing, Parts);
                    MyDrawing.PlaceViews();

                    DrawingHandler.CloseActiveDrawing(true); //Сохранение и закрытие активного окна
                }

                if (MyDrawing != null && openDrawings.Checked)
                {
                    DrawingHandler.SetActiveDrawing(MyDrawing);
                }

                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current); //возврат исходной плоскости
            }
            catch (Exception exception)
            {
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
                MessageBox.Show(exception.ToString());
            }
        }