private static void createText(List <TSD.Text> input, List <TSD.Text> output, __ViewBaseData inputData, __ViewBaseData outputData) { foreach (TSD.Text inputText in input) { T3D.Point insertionPoint = __GeometryOperations.applyGlobalOffset(inputText.InsertionPoint); bool found = false; //foreach (TSD.Text outputText in output) //{ // if (outputText.InsertionPoint == insertionPoint && outputText.TextString == inputText.TextString) // { // found = true; // break; // } //} if (found == false) { TSD.Text outputText = new TSD.Text(outputData.view, insertionPoint, inputText.TextString); outputText.Placing = inputText.Placing; outputText.Attributes = inputText.Attributes; outputText.Insert(); } } }
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(); } }
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; } }