예제 #1
0
        /// <summary>
        /// The get selected objects.
        /// </summary>
        /// <returns>
        /// The System.Collections.ArrayList.
        /// </returns>
        public ArrayList GetSelectedObjects()
        {
            var selectedObjects = new ArrayList();

            if (this.model != null)
            {
                var selector = this.model.GetModelObjectSelector();
                var modelObjectEnumerator = new TSMUI.ModelObjectSelector().GetSelectedObjects();
                modelObjectEnumerator.SelectInstances = false;

                try
                {
                    while (modelObjectEnumerator.MoveNext())
                    {
                        selectedObjects.Add(modelObjectEnumerator.Current);
                    }
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee.ToString());
                }
            }

            return(selectedObjects);
        }
예제 #2
0
        public void Run(String args)
        {
            XmlTextWriter myXmlTextWriter = null;
            int           Count           = 0;
            int           AssemblyId      = 0;
            long          TotalTime       = 0;
            long          ElapsedTime     = 0;
            long          StartTicks      = DateTime.Now.Ticks;

            try
            {
                ArrayList listOfPieces = new ArrayList();
                Model     myModel      = new Model();

                ModelObjectEnumerator myEnum = new TSMUI.ModelObjectSelector().GetSelectedObjects();

                myXmlTextWriter            = new XmlTextWriter(args, null);
                myXmlTextWriter.Formatting = Formatting.Indented;
                myXmlTextWriter.WriteStartDocument(false);
                myXmlTextWriter.WriteComment("This file is just a sample output from Tekla Structures");
                myXmlTextWriter.WriteStartElement("project");
                StartTicks = DateTime.Now.Ticks;

                while (myEnum.MoveNext())
                {
                    Part myPart = myEnum.Current as Part;
                    if ((myPart != null) && (myPart.GetReportProperty("ASSEMBLY.ID", ref AssemblyId)) &&
                        !listOfPieces.Contains(AssemblyId.ToString()))
                    {
                        WritePiece(myXmlTextWriter, myPart, myModel);
                        listOfPieces.Add(AssemblyId.ToString());
                        ++Count;
                        ElapsedTime = (DateTime.Now.Ticks - StartTicks) / 10000;
                        Console.WriteLine("{0} : {1} ({2} msecs)", Count, AssemblyId.ToString(), ElapsedTime);
                        TotalTime += ElapsedTime;
                        StartTicks = DateTime.Now.Ticks;
                    }
                }
                myXmlTextWriter.WriteEndElement();

                myXmlTextWriter.Flush();
                myXmlTextWriter.Close();
                ElapsedTime = (DateTime.Now.Ticks - StartTicks) / 10000;
                Console.WriteLine("Writing xml-file : {0} msecs", ElapsedTime);
                TotalTime += ElapsedTime;
            }
            catch (Exception Ex)
            {
                Console.WriteLine("Exceptioni : {0}", Ex.ToString());
            }

            finally
            {
                Console.WriteLine();
                Console.WriteLine("Totally {0} pieces exported.", Count);
                Console.WriteLine("Totla time spent : {0} seconds", (float)TotalTime / 1000);
                Console.WriteLine("Processing of the file {0} complete.", args);
                Console.WriteLine("\nPress enter ...");
                Console.Read();
                if (myXmlTextWriter != null)
                {
                    myXmlTextWriter.Close();
                }
            }
        }
예제 #3
0
        private void BtnCreate_Click(object sender, EventArgs e)
        {
            TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            try
            {
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());
                TSM.ModelObjectEnumerator selectedModelObjects = new TSMUI.ModelObjectSelector().GetSelectedObjects();

                TSD.GADrawing MyDrawing = null;

                while (selectedModelObjects.MoveNext())
                {
                    TSG.CoordinateSystem ModelObjectCoordSys;

                    string ModelObjectName;
                    string DrawingName = "Part basic views" + (selectedModelObjects.Current as TSM.ModelObject).Identifier;

                    GetCoordinateSystemAndNameOfSelectedObject(selectedModelObjects, out ModelObjectCoordSys, out ModelObjectName);

                    MyDrawing = new TSD.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 TSM.Part)
                    {
                        Parts.Add(selectedModelObjects.Current.Identifier);
                    }
                    else if (selectedModelObjects.Current is TSM.Assembly)
                    {
                        Parts = GetAssemblyParts(selectedModelObjects.Current as TSM.Assembly);
                    }
                    else if (selectedModelObjects.Current is TSM.BaseComponent)
                    {
                        Parts = GetComponentParts(selectedModelObjects.Current as TSM.BaseComponent);
                    }
                    else if (selectedModelObjects.Current is TSM.Task)
                    {
                        Parts = GetTaskParts(selectedModelObjects.Current as TSM.Task);
                    }

                    CreateViews(ModelObjectCoordSys, ModelObjectName, MyDrawing, Parts);

                    MyDrawing.PlaceViews();

                    drawingHandler.CloseActiveDrawing(true);
                }

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

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
            }
            catch (Exception Ex)
            {
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
                MessageBox.Show(Ex.Message);
            }
        }
예제 #4
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());
            }
        }