private void alignMarks(MarkBase baseMark, List <MarkBase> barMarks) { TSG.Point basePoint = baseMark.InsertionPoint; MarkBase[] sortedBarMarks = barMarks.ToArray(); Double[] sortedBarMarkXpos = new Double[barMarks.Count]; bool reversed = false; //create array of barmark positions for sorting for (int i = 0; i < sortedBarMarks.Length; i++) { TSDrg.LeaderLinePlacing placing = (LeaderLinePlacing)sortedBarMarks[i].Placing; //drawcircle(placing.StartPoint, sortedBarMarks[i].GetView()); sortedBarMarkXpos[i] = placing.StartPoint.X; } //sort and check for position of the basemark, if basemark is at the end, then reverse order of marks for sorting Array.Sort(sortedBarMarkXpos, sortedBarMarks); if (basePoint.X > sortedBarMarkXpos.Last()) { reversed = true; Array.Reverse(sortedBarMarks); Array.Reverse(sortedBarMarkXpos); } Double newInsertionYpos = basePoint.Y - PS.Default.usr_BarMarkYOffset; //move barmarks for (int i = 0; i < sortedBarMarks.Length; i++) { TSG.Point currBarMarkPosition = sortedBarMarks[i].InsertionPoint; double newInsertionXpos = 0.0; if (reversed == true) { newInsertionXpos = sortedBarMarkXpos[i] + 75 + sortedBarMarks[i].GetObjectAlignedBoundingBox().Width / 2; } else { newInsertionXpos = sortedBarMarkXpos[i] - 75 - sortedBarMarks[i].GetObjectAlignedBoundingBox().Width / 2; } TSG.Point newInsertionPoint = new TSG.Point(newInsertionXpos, newInsertionYpos); TSG.Vector moveVector = new TSG.Vector( newInsertionPoint.X - currBarMarkPosition.X, newInsertionPoint.Y - currBarMarkPosition.Y, 0.0); sortedBarMarks[i].MoveObjectRelative(moveVector); sortedBarMarks[i].Modify(); newInsertionYpos -= PS.Default.usr_BarMarkYOffset; } }
public void reCreateMark(_Mark input) { _mark.Attributes = input._mark.Attributes; _mark.Modify(); if (input._mark.Placing is TSD.LeaderLinePlacing) { TSD.LeaderLinePlacing attr = input._mark.Placing as TSD.LeaderLinePlacing; T3D.Point start = __GeometryOperations.applyGlobalOffset(attr.StartPoint); TSD.LeaderLinePlacing newPlacing = new TSD.LeaderLinePlacing(start); _mark.Placing = newPlacing; } else if (input._mark.Placing is TSD.AlongLinePlacing) { TSD.AlongLinePlacing attr = input._mark.Placing as TSD.AlongLinePlacing; T3D.Point start = __GeometryOperations.applyGlobalOffset(attr.StartPoint); T3D.Point end = __GeometryOperations.applyGlobalOffset(attr.EndPoint); TSD.AlongLinePlacing newPlacing = new TSD.AlongLinePlacing(start, end); _mark.Placing = newPlacing; } else if (input._mark.Placing is TSD.BaseLinePlacing) { //TSD.BaseLinePlacing attr = input._mark.Placing as TSD.BaseLinePlacing; //T3D.Point start = __GeometryOperations.applyGlobalOffset(attr.StartPoint); //T3D.Point end = __GeometryOperations.applyGlobalOffset(attr.EndPoint); //TSD.BaseLinePlacing newPlacing = new TSD.BaseLinePlacing(start, end); //_mark.Placing = newPlacing; } else if (input._mark.Placing is TSD.PointPlacing) { TSD.PointPlacing newPlacing = new TSD.PointPlacing(); _mark.Placing = newPlacing; } _mark.InsertionPoint = __GeometryOperations.applyGlobalOffset(input._mark.InsertionPoint); _mark.Modify(); _mark.Modify(); }
private void alignMarksHorizontal(List <MarkBase> barMarks) { MarkBase[] sortedBarMarks = barMarks.ToArray(); for (int i = 0; i < sortedBarMarks.Length; i++) { TSDrg.LeaderLinePlacing placing = (LeaderLinePlacing)sortedBarMarks[i].Placing; double newInsertionXpos = sortedBarMarks[i].InsertionPoint.X; double newInsertionYpos = placing.StartPoint.Y + sortedBarMarks[i].GetObjectAlignedBoundingBox().Height / 2; TSG.Point currBarMarkPosition = sortedBarMarks[i].InsertionPoint; TSG.Point newInsertionPoint = new TSG.Point(newInsertionXpos, newInsertionYpos); TSG.Vector moveVector = new TSG.Vector( newInsertionPoint.X - currBarMarkPosition.X, newInsertionPoint.Y - currBarMarkPosition.Y, 0.0); sortedBarMarks[i].MoveObjectRelative(moveVector); sortedBarMarks[i].Modify(); } }
private void reCreateMarkSmarts(_Mark other) { _mark.Attributes = other._mark.Attributes; _mark.Attributes.Frame.Color = TSD.DrawingColors.Green; _mark.Modify(); T3D.Point inputStart = __GeometryOperations.factor1Point((other._part as TSM.Beam).StartPoint, other._view as TSD.View); inputStart = __GeometryOperations.applyGlobalOffset(inputStart); T3D.Point inputEnd = __GeometryOperations.factor1Point((other._part as TSM.Beam).EndPoint, other._view as TSD.View); inputEnd = __GeometryOperations.applyGlobalOffset(inputEnd); T3D.Point outputStart = __GeometryOperations.factor1Point((this._part as TSM.Beam).StartPoint, this._view as TSD.View); T3D.Point outputEnd = __GeometryOperations.factor1Point((this._part as TSM.Beam).EndPoint, this._view as TSD.View); T3D.Point markOffset = __GeometryOperations.getLocalOffset(inputStart, outputStart); double alfa = __GeometryOperations.getAlfa(inputStart, inputEnd, outputStart, outputEnd); T3D.Point insertion = __GeometryOperations.applyGlobalOffset(other._mark.InsertionPoint); insertion = __GeometryOperations.applyLocalOffset(insertion, markOffset); if (other._mark.Placing is TSD.LeaderLinePlacing) { TSD.LeaderLinePlacing attr = other._mark.Placing as TSD.LeaderLinePlacing; T3D.Point start = __GeometryOperations.applyGlobalOffset(attr.StartPoint); start = __GeometryOperations.applyLocalOffset(start, markOffset); T3D.Point placingOffset = __GeometryOperations.getPlacingOffset(start, outputStart, alfa); T3D.Point insertionOffset = __GeometryOperations.getLocalOffset(start, insertion); start = __GeometryOperations.applyLocalOffset(outputStart, placingOffset); insertion = __GeometryOperations.applyLocalOffset(start, insertionOffset); TSD.LeaderLinePlacing newPlacing = new TSD.LeaderLinePlacing(start); _mark.Placing = newPlacing; } else if (other._mark.Placing is TSD.AlongLinePlacing) { TSD.AlongLinePlacing attr = other._mark.Placing as TSD.AlongLinePlacing; T3D.Point start = __GeometryOperations.applyGlobalOffset(attr.StartPoint); start = __GeometryOperations.applyLocalOffset(start, markOffset); T3D.Point placingOffset = __GeometryOperations.getPlacingOffset(outputStart, start, alfa); T3D.Point insertionOffset = __GeometryOperations.getLocalOffset(start, insertion); start = __GeometryOperations.applyLocalOffset(start, placingOffset); insertion = __GeometryOperations.applyLocalOffset(start, insertionOffset); T3D.Point end = __GeometryOperations.applyGlobalOffset(attr.EndPoint); end = __GeometryOperations.applyLocalOffset(end, markOffset); end = __GeometryOperations.applyLocalOffset(end, placingOffset); TSD.AlongLinePlacing newPlacing = new TSD.AlongLinePlacing(start, end); _mark.Placing = newPlacing; } else if (other._mark.Placing is TSD.BaseLinePlacing) { //TSD.BaseLinePlacing attr = input._mark.Placing as TSD.BaseLinePlacing; //T3D.Point start = __GeometryOperations.applyGlobalOffset(attr.StartPoint); //start = __GeometryOperations.applyLocalOffset(start, markOffset); //T3D.Point placingOffset = __GeometryOperations.getPlacingOffset(startPointRefactor, start, alfa); //T3D.Point insertionOffset = __GeometryOperations.getLocalOffset(start, insertion); //start = __GeometryOperations.applyLocalOffset(start, placingOffset); //insertion = __GeometryOperations.applyLocalOffset(start, insertionOffset); //T3D.Point end = __GeometryOperations.applyGlobalOffset(attr.EndPoint); //end = __GeometryOperations.applyLocalOffset(end, markOffset); //end = __GeometryOperations.applyLocalOffset(end, placingOffset); //TSD.BaseLinePlacing newPlacing = new TSD.BaseLinePlacing(start, end); //_mark.Placing = newPlacing; } else if (other._mark.Placing is TSD.PointPlacing) { TSD.PointPlacing newPlacing = new TSD.PointPlacing(); _mark.Placing = newPlacing; } _mark.InsertionPoint = insertion; _mark.Modify(); _mark.Modify(); }
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; } }