public static void Run(Tekla.Technology.Akit.IScript akit) { Model model = new Model(); //Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); DrawingHandler dh = new DrawingHandler(); DrawingObjectEnumerator doe = dh.GetDrawingObjectSelector().GetSelected(); while (doe.MoveNext()) { string CONN_CODE_END1 = "", CONN_CODE_END2 = ""; if (doe.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part dPart = (Tekla.Structures.Drawing.Part)doe.Current; Tekla.Structures.Model.Part mPart = (Tekla.Structures.Model.Part)model.SelectModelObject((Identifier)dPart.ModelIdentifier); if (mPart is Beam) { Beam beam = (Beam)mPart; ViewBase view = dPart.GetView(); mPart.GetUserProperty("CONN_CODE_END1", ref CONN_CODE_END1); mPart.GetUserProperty("CONN_CODE_END2", ref CONN_CODE_END2); if (CONN_CODE_END1 != "") { Tekla.Structures.Drawing.Text text = new Tekla.Structures.Drawing.Text(view, beam.StartPoint + new Point(200, 200), CONN_CODE_END1, new LeaderLinePlacing(beam.StartPoint)); text.Insert(); } if (CONN_CODE_END2 != "") { Tekla.Structures.Drawing.Text text = new Tekla.Structures.Drawing.Text(view, beam.EndPoint + new Point(200, 200), CONN_CODE_END2, new LeaderLinePlacing(beam.EndPoint)); text.Insert(); } } } } }
private void addFCRNote(ViewBase view, TSG.Point insertionPoint, ReinforcementBase rebarObject) { string fcrNumber = getPhaseNameFromReinforcement(rebarObject); fcrNumber = fcrNumber.Trim(); if (fcrNumber.LastIndexOf(" ") > 0) { fcrNumber = fcrNumber.Substring(0, fcrNumber.LastIndexOf(" ", fcrNumber.Length)); } TSDrg.Text fcrNote = new TSDrg.Text(view, insertionPoint, fcrNumber, new TSDrg.Text.TextAttributes(PS.Default.usr_FcrNote)); fcrNote.Insert(); view.GetDrawing().CommitChanges(); }
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(); } }
public void Modify(PropertyValueChangedEventArgs e) { try { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Text) { Tekla.Structures.Drawing.Text text = (Tekla.Structures.Drawing.Text)drawingObjectEnum.Current; if (label == "PreferredPlacingType") { Text.TextAttributes textAttributes = text.Attributes; if (preferredPlacingType == PreferredPlacingEnum.PointPlacingType) { textAttributes.PreferredPlacing = PreferredPlacingTypes.PointPlacingType(); } else if (preferredPlacingType == PreferredPlacingEnum.LeaderLinePlacingType) { textAttributes.PreferredPlacing = PreferredPlacingTypes.LeaderLinePlacingType(); } } if (label == "TextString") { string formattedText = ""; string[] split = textString.Split(new char[] { '¬' }); foreach (string temp in split) { formattedText = formattedText + temp + Environment.NewLine; } formattedText = formattedText.Trim(); text.TextString = formattedText; } if (label == "FontColour") { text.Attributes.Font.Color = fontColour; } if (label == "FontHeight") { text.Attributes.Font.Height = double.Parse(fontHeight); } if (label == "FontName") { text.Attributes.Font.Name = fontName; } if (label == "FontBold") { text.Attributes.Font.Bold = bool.Parse(fontBold.ToString()); } if (label == "FontItalic") { text.Attributes.Font.Italic = bool.Parse(fontItalic.ToString()); } if (label == "TextAngle") { text.Attributes.Angle = double.Parse(textAngle); } if (label == "TextAlignment") { if (textAlignment == TextAlignmentEnum.Center) { text.Attributes.Alignment = Tekla.Structures.Drawing.TextAlignment.Center; } else if (textAlignment == TextAlignmentEnum.Left) { text.Attributes.Alignment = Tekla.Structures.Drawing.TextAlignment.Left; } else if (textAlignment == TextAlignmentEnum.Right) { text.Attributes.Alignment = Tekla.Structures.Drawing.TextAlignment.Right; } } if (label == "FrameType") { if (frameType == FrameTypeEnum.Circle) { text.Attributes.Frame.Type = FrameTypes.Circle; } else if (frameType == FrameTypeEnum.Diamond) { text.Attributes.Frame.Type = FrameTypes.Diamond; } else if (frameType == FrameTypeEnum.Hexagon) { text.Attributes.Frame.Type = FrameTypes.Hexagon; } else if (frameType == FrameTypeEnum.Line) { text.Attributes.Frame.Type = FrameTypes.Line; } else if (frameType == FrameTypeEnum.None) { text.Attributes.Frame.Type = FrameTypes.None; } else if (frameType == FrameTypeEnum.Rectangular) { text.Attributes.Frame.Type = FrameTypes.Rectangular; } else if (frameType == FrameTypeEnum.Round) { text.Attributes.Frame.Type = FrameTypes.Round; } else if (frameType == FrameTypeEnum.Sharpened) { text.Attributes.Frame.Type = FrameTypes.Sharpened; } else if (frameType == FrameTypeEnum.Triangle) { text.Attributes.Frame.Type = FrameTypes.Triangle; } } if (label == "FrameColour") { text.Attributes.Frame.Color = frameColour; } if (label == "ArrowheadType") { if (arrowheadType == ArrowheadTypeEnum.CircleArrow) { text.Attributes.ArrowHead.Head = ArrowheadTypes.CircleArrow; } else if (arrowheadType == ArrowheadTypeEnum.FilledArrow) { text.Attributes.ArrowHead.Head = ArrowheadTypes.FilledArrow; } else if (arrowheadType == ArrowheadTypeEnum.FilledCircleArrow) { text.Attributes.ArrowHead.Head = ArrowheadTypes.FilledCircleArrow; } else if (arrowheadType == ArrowheadTypeEnum.LineArrow) { text.Attributes.ArrowHead.Head = ArrowheadTypes.LineArrow; } } if (label == "ArrowheadPosition") { if (arrowheadPosition == ArrowheadPositionEnum.Both) { text.Attributes.ArrowHead.ArrowPosition = ArrowheadPositions.Both; } else if (arrowheadPosition == ArrowheadPositionEnum.End) { text.Attributes.ArrowHead.ArrowPosition = ArrowheadPositions.End; } else if (arrowheadPosition == ArrowheadPositionEnum.None) { text.Attributes.ArrowHead.ArrowPosition = ArrowheadPositions.None; } else if (arrowheadPosition == ArrowheadPositionEnum.Start) { text.Attributes.ArrowHead.ArrowPosition = ArrowheadPositions.Start; } } if (label == "ArrowheadWidth") { text.Attributes.ArrowHead.Width = double.Parse(arrowheadWidth); } if (label == "ArrowheadHeight") { text.Attributes.ArrowHead.Height = double.Parse(arrowheadHeight); } text.Modify(); drawing.CommitChanges(); } } } catch { } }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Text) { Tekla.Structures.Drawing.Text text = (Tekla.Structures.Drawing.Text)drawingObjectEnum.Current; Text.TextAttributes textAttributes = text.Attributes; if (textAttributes.PreferredPlacing.ToString() == "Tekla.Structures.Drawing.PointPlacingType") { preferredPlacingType = PreferredPlacingEnum.PointPlacingType; } else if (textAttributes.PreferredPlacing.ToString() == "Tekla.Structures.Drawing.LeaderLinePlacingType") { preferredPlacingType = PreferredPlacingEnum.LeaderLinePlacingType; } textString = text.TextString.Replace("\n", "¬"); fontColour = text.Attributes.Font.Color; fontHeight = text.Attributes.Font.Height.ToString(); fontName = text.Attributes.Font.Name; if (text.Attributes.Font.Bold) { fontBold = Bool.True; } else { fontBold = Bool.False; } if (text.Attributes.Font.Italic) { fontItalic = Bool.True; } else { fontItalic = Bool.False; } textAngle = text.Attributes.Angle.ToString(); if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Center) { textAlignment = TextAlignmentEnum.Center; } else if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Left) { textAlignment = TextAlignmentEnum.Left; } else if (text.Attributes.Alignment == Tekla.Structures.Drawing.TextAlignment.Right) { textAlignment = TextAlignmentEnum.Right; } if (text.Attributes.Frame.Type == FrameTypes.Circle) { frameType = FrameTypeEnum.Circle; } else if (text.Attributes.Frame.Type == FrameTypes.Diamond) { frameType = FrameTypeEnum.Diamond; } else if (text.Attributes.Frame.Type == FrameTypes.Hexagon) { frameType = FrameTypeEnum.Hexagon; } else if (text.Attributes.Frame.Type == FrameTypes.Line) { frameType = FrameTypeEnum.Line; } else if (text.Attributes.Frame.Type == FrameTypes.None) { frameType = FrameTypeEnum.None; } else if (text.Attributes.Frame.Type == FrameTypes.Rectangular) { frameType = FrameTypeEnum.Rectangular; } else if (text.Attributes.Frame.Type == FrameTypes.Round) { frameType = FrameTypeEnum.Round; } else if (text.Attributes.Frame.Type == FrameTypes.Sharpened) { frameType = FrameTypeEnum.Sharpened; } else if (text.Attributes.Frame.Type == FrameTypes.Triangle) { frameType = FrameTypeEnum.Triangle; } frameColour = text.Attributes.Frame.Color; if (text.Attributes.ArrowHead.Head == ArrowheadTypes.CircleArrow) { arrowheadType = ArrowheadTypeEnum.CircleArrow; } else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.FilledArrow) { arrowheadType = ArrowheadTypeEnum.FilledArrow; } else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.FilledCircleArrow) { arrowheadType = ArrowheadTypeEnum.FilledCircleArrow; } else if (text.Attributes.ArrowHead.Head == ArrowheadTypes.LineArrow) { arrowheadType = ArrowheadTypeEnum.LineArrow; } if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.Both) { arrowheadPosition = ArrowheadPositionEnum.Both; } else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.End) { arrowheadPosition = ArrowheadPositionEnum.End; } else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.None) { arrowheadPosition = ArrowheadPositionEnum.None; } else if (text.Attributes.ArrowHead.ArrowPosition == ArrowheadPositions.Start) { arrowheadPosition = ArrowheadPositionEnum.Start; } arrowheadWidth = text.Attributes.ArrowHead.Width.ToString(); arrowheadHeight = text.Attributes.ArrowHead.Height.ToString(); } } } else if (drawingObjectEnum.GetSize() > 1) { preferredPlacingType = new PreferredPlacingEnum(); textString = ""; FontColour = new DrawingColors(); fontHeight = ""; fontName = ""; fontBold = new Bool(); fontItalic = new Bool(); textAngle = ""; textAlignment = new TextAlignmentEnum(); frameType = new FrameTypeEnum(); FrameColour = new DrawingColors(); arrowheadType = new ArrowheadTypeEnum(); arrowheadPosition = new ArrowheadPositionEnum(); arrowheadWidth = ""; arrowheadHeight = ""; } }
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; } }
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); } }