private static void createLinesNoOffset(List <TSD.Line> input, List <TSD.Line> output, TSD.ViewBase inputView, TSD.ViewBase outputView)
        {
            foreach (TSD.Line inputLine in input)
            {
                T3D.Point startPoint = inputLine.StartPoint;
                T3D.Point endPoint   = inputLine.EndPoint;

                bool found = false;
                foreach (TSD.Line outputLine in output)
                {
                    if (outputLine.StartPoint == startPoint && outputLine.EndPoint == endPoint)
                    {
                        found = true;
                        break;
                    }
                }

                if (found == false)
                {
                    TSD.Line outputLine = new TSD.Line(outputView, startPoint, endPoint, inputLine.Attributes);
                    outputLine.Attributes = inputLine.Attributes;
                    outputLine.Insert();
                }
            }
        }
 private void drawLine(Point p1, Point p2, ViewBase view)
 {
     TSD.Line newLine = new TSD.Line(view, p1, p2);
     LineTypeAttributes lineParams = new LineTypeAttributes(LineTypes.SolidLine, DrawingColors.Black);
     newLine.Attributes.Line = lineParams;
     newLine.Insert();
 }
Exemplo n.º 3
0
        private void drawLine(Point p1, Point p2, ViewBase view)
        {
            TSD.Line           newLine    = new TSD.Line(view, p1, p2);
            LineTypeAttributes lineParams = new LineTypeAttributes(LineTypes.SolidLine, DrawingColors.Black);

            newLine.Attributes.Line = lineParams;
            newLine.Insert();
        }
 internal static void InsertLine(ViewBase view, Point start, Point end)
 {
     TSD.Line line = new TSD.Line(view, start, end);
     TSD.Line.LineAttributes lineAttributes = new TSD.Line.LineAttributes();
     lineAttributes.Arrowhead =
         new ArrowheadAttributes(ArrowheadPositions.End, ArrowheadTypes.FilledArrow, 2, 3);
     lineAttributes.Line =
         new LineTypeAttributes(LineTypes.SolidLine, DrawingColors.Black);
     line.Attributes = lineAttributes;
     line.Insert();
     line.Modify();
 }
        private static List <OpenGraphicObject> DrawEllipseWithArcs(int precision, ViewBase selectedView, List <Point> ellipsePoints)
        {
            Arc arc;
            List <OpenGraphicObject> ellipse = new List <OpenGraphicObject>();
            Point centerPoint = null;

            for (int i = 0; i < precision - 2; i += 2)
            {
                centerPoint = GetCenterPointOfArc(ellipsePoints[i + 2], ellipsePoints[i + 1], ellipsePoints[i]);
                if (centerPoint != null)
                {
                    arc = new Arc(selectedView, ellipsePoints[i + 2], ellipsePoints[i], centerPoint);
                    if (arc.Insert())
                    {
                        ellipse.Add(arc);
                    }
                }
                else
                {
                    Line line = new Line(selectedView, ellipsePoints[i + 2], ellipsePoints[i]);
                    if (line.Insert())
                    {
                        ellipse.Add(line);
                    }
                }
            }

            centerPoint = GetCenterPointOfArc(ellipsePoints[0], ellipsePoints[precision - 1], ellipsePoints[precision - 2]);
            if (centerPoint != null)
            {
                arc = new Arc(selectedView, ellipsePoints[0], ellipsePoints[precision - 2], centerPoint);
                if (arc.Insert())
                {
                    ellipse.Add(arc);
                }
            }
            else
            {
                Line line = new Line(selectedView, ellipsePoints[0], ellipsePoints[precision - 2]);
                if (line.Insert())
                {
                    ellipse.Add(line);
                }
            }
            return(ellipse);
        }
Exemplo n.º 6
0
        internal static void InsertLine(ViewBase view, Point start, Point end)
        {
            if (start != null && end != null)
            {
                TSD.Line line = new TSD.Line(view,
                                             Extensions.TransformPointToDisplay(start, view),
                                             Extensions.TransformPointToDisplay(end, view));

                TSD.Line.LineAttributes la = new TSD.Line.LineAttributes();
                la.Line.Type    = LineTypes.DashDot;
                la.Line.Color   = DrawingColors.Black;
                line.Attributes = la;

                line.Insert();
                line.Modify();
            }
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
        public void addOneObject(TSD.DrawingObject dro)
        {
            if (dro is TSD.Mark)
            {
                TSD.Mark current = dro as TSD.Mark;
                markHandler(current);
            }

            else if (dro is TSD.StraightDimensionSet)
            {
                TSD.StraightDimensionSet current = dro as TSD.StraightDimensionSet;
                _StraightDimentionSet    temp    = new _StraightDimentionSet(current);
                straightDimSets.Add(temp);
            }

            else if (dro is TSD.SectionMark)
            {
                TSD.SectionMark current = dro as TSD.SectionMark;
                _SectionMark    temp    = new _SectionMark(current);
                sectionMarks.Add(temp);
            }

            else if (dro is TSD.DetailMark)
            {
                TSD.DetailMark current = dro as TSD.DetailMark;
                detailMarks.Add(current);
            }

            else if (dro is TSD.Text)
            {
                TSD.Text current = dro as TSD.Text;
                txt.Add(current);
            }

            else if (dro is TSD.Arc)
            {
                TSD.Arc current = dro as TSD.Arc;
                arcs.Add(current);
            }

            else if (dro is TSD.Line)
            {
                TSD.Line current = dro as TSD.Line;
                lines.Add(current);
            }

            else if (dro is TSD.Polyline)
            {
                TSD.Polyline current = dro as TSD.Polyline;
                polylines.Add(current);
            }

            else if (dro is TSD.Circle)
            {
                TSD.Circle current = dro as TSD.Circle;
                circles.Add(current);
            }

            else if (dro is TSD.Cloud)
            {
                TSD.Cloud current = dro as TSD.Cloud;
                clouds.Add(current);
            }

            else if (dro is TSD.Rectangle)
            {
                TSD.Rectangle current = dro as TSD.Rectangle;
                rectangles.Add(current);
            }

            else if (dro is TSD.Polygon)
            {
                TSD.Polygon current = dro as TSD.Polygon;
                polygons.Add(current);
            }

            else if (dro is TSD.TextFile)
            {
                TSD.TextFile current = dro as TSD.TextFile;
                txtFiles.Add(current);
            }

            else if (dro is TSD.DwgObject)
            {
                TSD.DwgObject current = dro as TSD.DwgObject;
                dwgRefs.Add(current);
            }
        }