private static void getPoint(__DrawingData drawing)
        {
            TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();

            if (drawingHandler.GetConnectionStatus())
            {
                TSD.ContainerView sheet = drawingHandler.GetActiveDrawing().GetSheet();

                TSD.UI.Picker picker       = drawingHandler.GetPicker();
                T3D.Point     viewPoint    = null;
                TSD.ViewBase  selectedView = null;

                MainForm._form.add_text("Select origin point in drawing view");
                picker.PickPoint("Pick one point", out viewPoint, out selectedView);
                T3D.Point sheetPoint = TSD.Tools.DrawingCoordinateConverter.Convert(selectedView, sheet, viewPoint);

                if (selectedView != null)
                {
                    if (selectedView is TSD.View)
                    {
                        drawing.setView(selectedView as TSD.View);
                    }
                }

                drawing.setSheet(sheet);
                drawing.setPoints(viewPoint, sheetPoint);
            }
        }
Beispiel #2
0
        private Tuple <TSDrg.PointList, TSDrg.View> getRectangleCornersFromUser()
        {
            TSDrg.DrawingHandler myDrawingHandler = new TSDrg.DrawingHandler();
            TSDrg.UI.Picker      pointPicker      = myDrawingHandler.GetPicker();
            TSDrg.PointList      myPoints         = null;
            TSDrg.ViewBase       myViewBase       = null;
            TSDrg.View           myView           = myViewBase as TSDrg.View;
            TSDrg.StringList     promptMsg        = new TSDrg.StringList();
            promptMsg.Add("Select first corner of the rectangle");
            promptMsg.Add("Select second corner of the rectangle");

            try
            {
                pointPicker.PickPoints(2, promptMsg, out myPoints, out myViewBase);
                myView = myViewBase as TSDrg.View;

                while (myView == null)
                {
                    pointPicker.PickPoints(2, promptMsg, out myPoints, out myViewBase);
                    myView = myViewBase as TSDrg.View;
                }

                return(new Tuple <TSDrg.PointList, TSDrg.View>(myPoints, myView));
            }

            catch (Tekla.Structures.Drawing.PickerInterruptedException interrupted)
            {
                //Tekla.Structures.Model.Operations.Operation.DisplayPrompt("THIS METHOD NOT WORKING BECAUSE TEKLA API IS THE WORST THING I HAVE EVER WORKED WITH");
                lbl_info.Text = "User interrupted action.";
                return(new Tuple <TSDrg.PointList, TSDrg.View>(myPoints, myView));
            }
        }
Beispiel #3
0
        private Tuple <TSG.Point, TSDrg.View> getPointFromUser()
        {
            TSDrg.DrawingHandler myDrawingHandler = new TSDrg.DrawingHandler();
            TSDrg.UI.Picker      pointPicker      = myDrawingHandler.GetPicker();
            TSG.Point            myPoint          = null;
            TSDrg.ViewBase       myViewBase       = null;
            TSDrg.View           myView           = myViewBase as TSDrg.View;

            try
            {
                pointPicker.PickPoint("Pick a point to insert an FCR note", out myPoint, out myViewBase);
                myView = myViewBase as TSDrg.View;

                while (myView == null)
                {
                    pointPicker.PickPoint("Selected point is not inside a view. Pick a point to insert an FCR note", out myPoint, out myViewBase);
                    myView = myViewBase as TSDrg.View;
                }

                return(new Tuple <TSG.Point, TSDrg.View>(myPoint, myView));
            }

            catch (Tekla.Structures.Drawing.PickerInterruptedException interrupted)
            {
                //Tekla.Structures.Model.Operations.Operation.DisplayPrompt("THIS METHOD NOT WORKING BECAUSE TEKLA API IS THE WORST THING I HAVE EVER WORKED WITH");
                lbl_info.Text = "User interrupted action.";
                return(new Tuple <TSG.Point, TSDrg.View>(myPoint, myView));
            }
        }
Beispiel #4
0
        private DrawingObject getSingleObjectFromUser <T>()
        {
            DrawingHandler myDrawingHandler = new TSDrg.DrawingHandler();

            TSDrg.UI.Picker pointPicker = myDrawingHandler.GetPicker();
            DrawingObject   usrObject   = null;
            ViewBase        myViewBase  = null;

            TSDrg.View myView = myViewBase as TSDrg.View;

            try
            {
                pointPicker.PickObject("Please select a bar", out usrObject, out myViewBase);
                myView = myViewBase as TSDrg.View;

                while (myView == null || !(usrObject is T))
                {
                    pointPicker.PickObject("Please select a bar", out usrObject, out myViewBase);
                    myView = myViewBase as TSDrg.View;
                }

                return(usrObject);
            }

            catch (Tekla.Structures.Drawing.PickerInterruptedException interrupted)
            {
                //Tekla.Structures.Model.Operations.Operation.DisplayPrompt("THIS METHOD NOT WORKING BECAUSE TEKLA API IS THE WORST THING I HAVE EVER WORKED WITH");
                lbl_info.Text = "User interrupted action.";
                return(usrObject);
            }
        }
Beispiel #5
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 { }
        }
Beispiel #6
0
        void ButtonDoClick(object sender, EventArgs e)
        {
            TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();

            TSD.UI.Picker picker = drawingHandler.GetPicker();

            TSG.Point    point1 = null;
            TSG.Point    point2 = null;
            TSG.Point    point3 = null;
            TSD.ViewBase view   = null;

            Shell shell = null;

            try
            {
                shell = new Shell(Convert.ToDouble(diameterTextBox.Text), Convert.ToDouble(thicknessTextBox.Text), chamferTopComboBox.SelectedItem.ToString(), chamferBotComboBox.SelectedItem.ToString(), Convert.ToDouble(angleTrimTextBox.Text), Convert.ToDouble(angleRotateTextBox.Text), Convert.ToDouble(angleSectorTextBox.Text), Convert.ToInt32(nPartTextBox.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            if (shell != null)
            {
                try
                {
                    picker.PickThreePoints("1st poit", "2nd point", "3rd point", out point1, out point2, out point3, out view);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }


                double angleP2 = GetAngle(new TSG.Point((point2.X - point1.X), (point2.Y - point1.Y)));
                double angleP3 = GetAngle(new TSG.Point(((point3.X - point1.X) * Math.Cos(-angleP2) - (point3.Y - point1.Y) * Math.Sin(-angleP2)), ((point3.X - point1.X) * Math.Sin(-angleP2) + (point3.Y - point1.Y) * Math.Cos(-angleP2))));

                int kof = ((angleP3 >= 0) && (angleP3 < Math.PI)) ? -1 : 1;

                double lArc = (shell.diameter / 2 - shell.thickness / 2) * shell.angleSector;

                for (int i = 0; i < shell.arrLine.Length; i++)
                {
                    TSG.Point p1 = new TSG.Point((point1.X + (i * lArc / shell.nPart) * Math.Cos(angleP2)), (point1.Y + (i * lArc / shell.nPart) * Math.Sin(angleP2)));
                    TSG.Point p2 = new TSG.Point((point1.X + i * lArc / shell.nPart * Math.Cos(angleP2) + kof * shell.arrLine[i] * Math.Sin(angleP2)), (point1.Y + i * lArc / shell.nPart * Math.Sin(angleP2) - kof * shell.arrLine[i] * Math.Cos(angleP2)));;

                    TSD.Text.TextAttributes txtAtributes = new TSD.Text.TextAttributes();
                    txtAtributes.Angle = angleP2 * 180 / Math.PI + 90;

                    string   dimText = (Math.Round(shell.arrLine[i]).ToString());
                    TSD.Text dim     = new TSD.Text(view, p1, dimText, txtAtributes);
                    dim.Insert();

                    TSD.Line line = new TSD.Line(view, p1, p2);
                    line.Insert();
                }



                TSD.Line line2 = new TSD.Line(view, point1, new TSG.Point((point1.X + lArc * Math.Cos(angleP2)), (point1.Y + lArc * Math.Sin(angleP2))));
                line2.Insert();
            }
        }
Beispiel #7
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;
            }
        }