Пример #1
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));
            }
        }
Пример #2
0
        private TSDrg.StraightDimensionSet CreateNewDim(TSDrg.View view, TSDrg.PointList pointList)
        {
            TSG.Vector upDirection;

            if (checkBox1.Checked)
            {
                upDirection = new TSG.Vector(1, 0, 0);
            }
            else if (checkBox2.Checked)
            {
                upDirection = new TSG.Vector(0, 1, 0);
            }
            else
            {
                lbl_status.Text = "Please select dimension orientation";
                upDirection     = new TSG.Vector(1, 0, 0);
            }

            double height = 0.0;

            TSDrg.StraightDimensionSet.StraightDimensionSetAttributes attr = new TSDrg.StraightDimensionSet.StraightDimensionSetAttributes();

            TSDrg.StraightDimensionSetHandler myDimSetHandler = new TSDrg.StraightDimensionSetHandler();
            TSDrg.StraightDimensionSet        newDim          = myDimSetHandler.CreateDimensionSet(view, pointList, upDirection, height, attr);
            return(newDim);
        }
Пример #3
0
 private void drawCloud(TSDrg.PointList pointList, ViewBase view, string attributesFile)
 {
     TSDrg.Cloud cloud = new TSDrg.Cloud(view, pointList, new Cloud.CloudAttributes(attributesFile));
     cloud.Attributes.Line.Color = TSDrg.DrawingColors.Red;
     cloud.Insert();
     view.GetDrawing().CommitChanges();
 }
Пример #4
0
        private TSDrg.PointList calculateRectanlgeFromCorners(TSDrg.PointList cornerList)
        {
            PointList rectangle = new PointList();

            TSG.Point[] corners = cornerList.ToArray();
            rectangle.Add(corners[0]);
            rectangle.Add(new TSG.Point(corners[1].X, corners[0].Y, 0.0));
            rectangle.Add(corners[1]);
            rectangle.Add(new TSG.Point(corners[0].X, corners[1].Y, 0.0));

            return(rectangle);
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //reset dialog
            resetFormStatus();

            //get insertion point inpit from user
            Tuple <TSG.Point, TSDrg.View> usrInp = GetPointViewFromUser();

            TSG.Point  basePoint = usrInp.Item1;
            TSG.Point  endPoint;
            TSDrg.View currentView = usrInp.Item2;

            if (basePoint == null)
            {
                return;
            }

            //create dimension
            foreach (DataGridViewRow row in dgv_dimTable.Rows)
            {
                if (row.Index < dgv_dimTable.Rows.Count - 1)
                {
                    var    dimLengthInp = row.Cells["dimLength"].Value;
                    double dimLength    = Convert.ToDouble(dimLengthInp.ToString());

                    if (checkBox1.Checked)
                    {
                        endPoint = new TSG.Point(basePoint.X, basePoint.Y + dimLength);
                    }
                    else if (checkBox2.Checked)
                    {
                        endPoint = new TSG.Point(basePoint.X + dimLength, basePoint.Y);
                    }
                    else
                    {
                        lbl_status.Text = "Please select dimension orientation";
                        return;
                    }


                    TSDrg.PointList pointList = new TSDrg.PointList();
                    pointList.Add(basePoint);
                    pointList.Add(endPoint);

                    TSDrg.StraightDimensionSet newDimSet = CreateNewDim(currentView, pointList);
                    newDimSet.Select();
                    newDimSet.Attributes.LoadAttributes(txb_preset.Text);
                    newDimSet.Modify();
                    basePoint = endPoint;
                }
            }
        }
Пример #6
0
        private void btn_addCloud_Click(object sender, EventArgs e)
        {
            resetForm();

            var(points, view) = getRectangleCornersFromUser();

            if (points != null)
            {
                TSDrg.PointList rectangle = calculateRectanlgeFromCorners(points);
                drawCloud(rectangle, view, PS.Default.usr_Cloud);
            }
            else
            {
                lbl_info.Text = "Action interrupted;";
            }
        }
        private static void createPolygons(List <TSD.Polygon> input, List <TSD.Polygon> output, TSD.ViewBase inputView, TSD.ViewBase outputView)
        {
            foreach (TSD.Polygon inputPoly in input)
            {
                TSD.PointList pts = new TSD.PointList();

                foreach (T3D.Point pt in inputPoly.Points)
                {
                    T3D.Point temp = __GeometryOperations.applyGlobalOffset(pt);
                    pts.Add(temp);
                }

                bool found = false;
                bool same  = true;
                foreach (TSD.Polygon outputPoly in output)
                {
                    if (outputPoly.Points.Count == pts.Count)
                    {
                        if (outputPoly.Points.Count != 0)
                        {
                            for (int i = 0; i < outputPoly.Points.Count; i++)
                            {
                                T3D.Point oldpt = outputPoly.Points[0];
                                T3D.Point newpt = pts[0];

                                if (__GeometryOperations.compare2Points(oldpt, newpt) == false)
                                {
                                    same = false;
                                    break;
                                }
                            }

                            if (same == true)
                            {
                                found = true;
                                break;
                            }

                            for (int i = 0; i < outputPoly.Points.Count; i++)
                            {
                                T3D.Point oldpt = outputPoly.Points[0];
                                T3D.Point newpt = pts[pts.Count - i - 1];

                                if (__GeometryOperations.compare2Points(oldpt, newpt) == false)
                                {
                                    same = false;
                                    break;
                                }
                            }

                            if (same == true)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                }

                if (found == false)
                {
                    TSD.Polygon outputLine = new TSD.Polygon(outputView, pts, inputPoly.Attributes);
                    outputLine.Attributes = inputPoly.Attributes;
                    outputLine.Insert();
                }
            }
        }
        private static void createDimentionLineSets(List <_StraightDimentionSet> input, List <_StraightDimentionSet> output, TSD.ViewBase outputView)
        {
            foreach (_StraightDimentionSet inputDimSet in input)
            {
                TSD.PointList outputPoints = new TSD.PointList();
                foreach (T3D.Point ip in inputDimSet._points)
                {
                    T3D.Point op = __GeometryOperations.applyGlobalOffset(ip);
                    outputPoints.Add(op);
                }

                bool found = false;
                _StraightDimentionSet outputDimSetCopy = null;

                foreach (_StraightDimentionSet outputDimSet in output)
                {
                    if (inputDimSet._points.Count == outputDimSet._points.Count)
                    {
                        if (outputDimSet._points.Count != 0)
                        {
                            bool local = true;
                            for (int i = 0; i < outputDimSet._points.Count; i++)
                            {
                                bool same = __GeometryOperations.compare2PointsNullTolerance(outputPoints[i], outputDimSet._points[i]);

                                if (same == false)
                                {
                                    local = false;
                                    break;
                                }
                            }

                            if (local == true)
                            {
                                if (outputDimSet._first.UpDirection == inputDimSet._first.UpDirection)
                                {
                                    found            = true;
                                    outputDimSetCopy = outputDimSet;
                                    break;
                                }
                            }
                        }
                    }
                }

                if (found == false)
                {
                    TSD.StraightDimensionSetHandler sds          = new TSD.StraightDimensionSetHandler();
                    TSD.StraightDimensionSet        outputDimSet = sds.CreateDimensionSet(outputView, outputPoints, inputDimSet._first.UpDirection, inputDimSet._set.Distance, inputDimSet._set.Attributes);
                    outputDimSet.Distance = inputDimSet._set.Distance;
                    outputDimSet.Modify();
                }
                else
                {
                    if (outputDimSetCopy != null)
                    {
                        outputDimSetCopy._set.Distance = inputDimSet._set.Distance;
                        outputDimSetCopy._set.Modify();
                    }
                }
            }
        }
Пример #9
0
 public _StraightDimentionSet(TSD.StraightDimensionSet obj)
 {
     _set    = obj as TSD.StraightDimensionSet;
     _points = new TSD.PointList();
     getDimSetPoints();
 }