Exemplo n.º 1
0
        //Pick a part from the drawing, to get its information
        //from the model
        private void PickObjectInDrawing_Click(object sender, EventArgs e)
        {
            try
            {
                _drawing = _drawingHandler.GetActiveDrawing();
                //Checks if any drawing is open
                if (_drawing != null)
                {
                    DrawingObject pickedObject;
                    ViewBase      pickedView;
                    Tekla.Structures.Geometry3d.Point pickedPoint;

                    //Pick a part in the model
                    Picker myPicker = _drawingHandler.GetPicker();
                    myPicker.PickObject("Pick a model object in the drawing", out pickedObject, out pickedView, out pickedPoint);
                    GetInfoFromDrawing(pickedObject);
                }
                else
                {
                    MessageBox.Show("A drawing must be opened in Tekla Structures model!");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
        }
        public override List <InputDefinition> DefineInput()
        {
            //
            // This is an example for selecting two points; change this to suit your needs.
            //
            List <InputDefinition> inputs         = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase  view   = null;
                PointList points = new PointList();

                StringList prompts = new StringList();
                prompts.Add("Pick first point");
                prompts.Add("Pick second point");

                picker.PickPoints(2, prompts, out points, out view);
                inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, points));
            }

            return(inputs);
        }
Exemplo n.º 3
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            //Idea is to get only objects in selected view
            ViewBase      view;
            DrawingObject dob;

            var    handler = new DrawingHandler();
            Picker picker  = handler.GetPicker();

            picker.PickObject("Select any object in intended view", out dob, out view);

            var reinforcement = view.GetAllObjects(typeof(ReinforcementBase));

            DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.BY_COMMIT);

            foreach (ReinforcementBase reinf in reinforcement)
            {
                if (reinf.Hideable.IsHidden)
                {
                    reinf.Hideable.ShowInDrawingView();
                    reinf.Modify();
                }
            }
            DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT);
            handler.GetActiveDrawing().CommitChanges();
            Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Operation finished");
        }
        public override List <InputDefinition> DefineInput()
        {
            var drawingHandler = new DrawingHandler();
            var picker         = drawingHandler.GetPicker();
            var pick           = picker.PickPoint("Pick a point");

            return(new List <InputDefinition>()
            {
                InputDefinitionFactory.CreateInputDefinition(pick)
            });
        }
        private void button2_Click(object sender, EventArgs e)
        {
            DrawingHandler dh = new DrawingHandler();

            Tekla.Structures.Geometry3d.Point point = null;
            Tekla.Structures.Drawing.ViewBase view  = null;
            dh.GetPicker().PickPoint("hi", out point, out view);
            Tekla.Structures.Geometry3d.Point endpoint = new Tekla.Structures.Geometry3d.Point();
            endpoint.X = 1142 + point.X;
            endpoint.Y = 815 + point.Y;
            Tekla.Structures.Drawing.Rectangle rectangle = new Tekla.Structures.Drawing.Rectangle(view, point, endpoint);
            rectangle.Insert();
            Tekla.Structures.Geometry3d.Point tpoint    = new Tekla.Structures.Geometry3d.Point(endpoint.X, point.Y);
            Tekla.Structures.Geometry3d.Point tendpoint = new Tekla.Structures.Geometry3d.Point();
            tendpoint.X = tpoint.X - 128;
            tendpoint.Y = tpoint.Y + 59;
            Tekla.Structures.Drawing.Rectangle titlebox = new Tekla.Structures.Drawing.Rectangle(view, tpoint, tendpoint);
            titlebox.Insert();
        }
Exemplo n.º 6
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> input          = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase      view       = null;
                DrawingObject pickedPart = null;

                picker.PickObject("Pick part", out pickedPart, out view);

                input.Add(InputDefinitionFactory.CreateInputDefinition(view, pickedPart));
            }

            return(input);
        }
Exemplo n.º 7
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> inputs         = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase  view   = null;
                PointList points = new PointList();

                StringList prompts = new StringList();
                prompts.Add("Pick first point");
                prompts.Add("Pick second point");

                picker.PickPoints(2, prompts, out points, out view);
                inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, points));
            }

            return(inputs);
        }
Exemplo n.º 8
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> inputs         = new List <InputDefinition>();
            DrawingHandler         drawingHandler = new DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                Picker picker = drawingHandler.GetPicker();

                ViewBase  view;
                PointList pointList;

                StringList promts = new StringList();
                promts.Add("able_Pick_center_point");
                promts.Add("able_Pick_major_point");

                picker.PickPoints(2, promts, out pointList, out view);
                inputs.Add(InputDefinitionFactory.CreateInputDefinition(view, pointList));
            }

            return(inputs);
        }
Exemplo n.º 9
0
        private void getPoints(out Point firstPoint, out Point secondPoint, out ViewBase view)
        {
            Picker picker = _drawingHandler.GetPicker();

            picker.PickTwoPoints("Vali ringi keskpunkt", "Vali punkt ringi kontuuril", out firstPoint, out secondPoint, out view);
        }
Exemplo n.º 10
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            try
            {
                Model          model          = new Model();
                DrawingHandler drawingHandler = new DrawingHandler();
                Drawing        drawing        = drawingHandler.GetActiveDrawing();

                if (drawing != null)
                {
                    Tekla.Structures.Drawing.StraightDimension sd   = null;
                    Tekla.Structures.Drawing.Bolt bolt              = null;
                    DrawingObjectEnumerator       drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected();
                    while (drawingObjectEnum.MoveNext())
                    {
                        if (drawingObjectEnum.Current is Tekla.Structures.Drawing.StraightDimension)
                        {
                            sd = (Tekla.Structures.Drawing.StraightDimension)drawingObjectEnum.Current;
                        }
                        if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Bolt)
                        {
                            bolt = (Tekla.Structures.Drawing.Bolt)drawingObjectEnum.Current;
                        }
                    }

                    if (bolt == null)
                    {
                        Tekla.Structures.Drawing.UI.Picker picker = drawingHandler.GetPicker();
                        DrawingObject drawingObject = null;
                        Tekla.Structures.Drawing.ViewBase viewBase    = null;
                        Tekla.Structures.Geometry3d.Point pickedPoint = null;
                        Type[] TypeFilter = new Type[] { typeof(Tekla.Structures.Drawing.Bolt) };

                        picker.PickObject("pick bolt", TypeFilter, out drawingObject, out viewBase, out pickedPoint);
                        bolt = (Tekla.Structures.Drawing.Bolt)drawingObject;
                    }

                    Tekla.Structures.Model.BoltGroup mBolt = (Tekla.Structures.Model.BoltGroup)model.SelectModelObject((Identifier)bolt.ModelIdentifier);
                    string note = "";
                    if (mBolt is BoltArray)
                    {
                        BoltArray boltArray = (BoltArray)mBolt;

                        if (boltArray.GetBoltDistYCount() == 1 && boltArray.GetBoltDistY(0) == 0)
                        {
                            note = (mBolt.BoltPositions.Count - 1).ToString() + " No SPACES @ " + boltArray.GetBoltDistX(1).ToString() + " = ";
                        }

                        if (boltArray.GetBoltDistY(0) > 0)
                        {
                        }
                    }
                    else if (mBolt is BoltXYList)
                    {
                        BoltXYList boltXYList = (BoltXYList)mBolt;
                        note = (boltXYList.BoltPositions.Count - 1).ToString() + " STAGGERED No SPACES @ " + (boltXYList.GetBoltDistX(1)).ToString() + " = ";
                    }

                    Tekla.Structures.Drawing.UI.DrawingObjectSelector drawingObjectSelector = drawingHandler.GetDrawingObjectSelector();
                    drawingObjectSelector.SelectObject(sd);

                    akit.ValueChange("main_frame", "gr_sel_dimension", "1");
                    akit.Callback("acmd_display_attr_dialog", "dim_dial", "main_frame");
                    akit.PushButton("dim_set", "dim_dial");
                    akit.TabChange("dim_dial", "tabWndDimAttrib", "tabMarks");
                    akit.PushButton("dim_on_off", "dim_dial");
                    akit.ValueChange("dim_dial", "txtFldPrefix", note);
                    akit.PushButton("dim_modify", "dim_dial");
                    akit.PushButton("dim_cancel", "dim_dial");
                }
            }
            catch { }
        }
        private void getPoints(out Point firstPoint, out Point secondPoint, out ViewBase view)
        {
            Picker picker = _drawingHandler.GetPicker();

            picker.PickTwoPoints("Vali esimene punkt", "Vali teine punkt", out firstPoint, out secondPoint, out view);
        }
Exemplo n.º 12
0
        private void PasteObjects_Click(object sender, EventArgs e)
        {
            try
            {
                Drawing drawing = drawingHandler.GetActiveDrawing();

                if (selectedPartsArray.Count > 0)
                {
                    Tekla.Structures.Drawing.View view = new Tekla.Structures.Drawing.View(drawing.GetSheet(), v.ViewCoordinateSystem, v.DisplayCoordinateSystem, selectedPartsArray);
                    view.Insert();
                }

                if (selectedViewsArray.Count > 0)
                {
                    foreach (Tekla.Structures.Drawing.View oView in selectedViewsArray)
                    {
                        Tekla.Structures.Drawing.View view = new Tekla.Structures.Drawing.View(drawing.GetSheet(), oView.ViewCoordinateSystem, oView.DisplayCoordinateSystem, oView.RestrictionBox);
                        view = oView;
                        view.Insert();
                    }
                }

                if (selectedObjectsArray.Count > 0)
                {
                    Tekla.Structures.Drawing.UI.Picker picker = drawingHandler.GetPicker();
                    Tekla.Structures.Geometry3d.Point  point  = null;
                    ViewBase selectedView = null;
                    picker.PickPoint("Pick View", out point, out selectedView);

                    foreach (DrawingObject drawingObject in selectedObjectsArray)
                    {
                        if (drawingObject is Tekla.Structures.Drawing.Text)
                        {
                            Tekla.Structures.Drawing.Text oText = (Tekla.Structures.Drawing.Text)drawingObject;
                            Tekla.Structures.Drawing.Text text  = new Tekla.Structures.Drawing.Text(selectedView, oText.InsertionPoint, oText.TextString, oText.Attributes);

                            if (oText.Placing is Tekla.Structures.Drawing.LeaderLinePlacing)
                            {
                                Tekla.Structures.Drawing.LeaderLinePlacing l = (Tekla.Structures.Drawing.LeaderLinePlacing)oText.Placing;
                                text = new Tekla.Structures.Drawing.Text(selectedView, oText.InsertionPoint, oText.TextString, new LeaderLinePlacing(l.StartPoint), oText.Attributes);
                                text.Insert();
                            }
                            else
                            {
                                text = new Tekla.Structures.Drawing.Text(selectedView, oText.InsertionPoint, oText.TextString, oText.Attributes);
                                text.Insert();
                            }
                        }

                        if (drawingObject is Tekla.Structures.Drawing.Line)
                        {
                            Tekla.Structures.Drawing.Line oLine = (Tekla.Structures.Drawing.Line)drawingObject;
                            Tekla.Structures.Drawing.Line line  = new Tekla.Structures.Drawing.Line(selectedView, oLine.StartPoint, oLine.EndPoint, oLine.Bulge, oLine.Attributes);
                            line.Insert();
                        }

                        if (drawingObject is Tekla.Structures.Drawing.Arc)
                        {
                            Tekla.Structures.Drawing.Arc oArc = (Tekla.Structures.Drawing.Arc)drawingObject;
                            Tekla.Structures.Drawing.Arc arc  = new Arc(selectedView, oArc.StartPoint, oArc.EndPoint, oArc.Radius, oArc.Attributes);
                            arc.Insert();
                        }

                        if (drawingObject is Tekla.Structures.Drawing.Polyline)
                        {
                            Tekla.Structures.Drawing.Polyline oPolyline = (Tekla.Structures.Drawing.Polyline)drawingObject;
                            Tekla.Structures.Drawing.Polyline polyline  = new Polyline(selectedView, oPolyline.Points, oPolyline.Attributes);
                            polyline.Bulge = oPolyline.Bulge;
                            polyline.Insert();
                        }

                        if (drawingObject is Tekla.Structures.Drawing.Rectangle)
                        {
                            Tekla.Structures.Drawing.Rectangle oRectangle = (Tekla.Structures.Drawing.Rectangle)drawingObject;
                            Tekla.Structures.Drawing.Rectangle rectangle  = new Tekla.Structures.Drawing.Rectangle(selectedView, oRectangle.StartPoint, oRectangle.Width, oRectangle.Height, oRectangle.Attributes);
                            rectangle.Angle = oRectangle.Angle;
                            rectangle.Insert();
                        }

                        if (drawingObject is Tekla.Structures.Drawing.Circle)
                        {
                            Tekla.Structures.Drawing.Circle oCircle = (Tekla.Structures.Drawing.Circle)drawingObject;
                            Tekla.Structures.Drawing.Circle circle  = new Circle(selectedView, oCircle.CenterPoint, oCircle.Radius, oCircle.Attributes);
                            circle.Insert();
                        }

                        if (drawingObject is Tekla.Structures.Drawing.Polygon)
                        {
                            Tekla.Structures.Drawing.Polygon oPolygon = (Tekla.Structures.Drawing.Polygon)drawingObject;
                            Tekla.Structures.Drawing.Polygon polygon  = new Tekla.Structures.Drawing.Polygon(selectedView, oPolygon.Points, oPolygon.Attributes);;
                            polygon.Bulge = oPolygon.Bulge;
                            polygon.Insert();
                        }
                    }
                }
                statusLabel.Text = "Objects pasted in drawing " + drawing.Mark.Substring(1, drawing.Mark.Length - 2);
            }
            catch (Exception ex)
            {
                statusLabel.Text = ex.Message;
            }
        }