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); }
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; } } }
private void modifyDim(TSDrg.StraightDimension line) { line.Select(); TSDrg.StraightDimensionSet sds = line.GetDimensionSet() as TSDrg.StraightDimensionSet; //TSDrg.FontAttributes fa = sds.Attributes.Text.Font; //TSDrg.FontAttributes oldFa = new TSDrg.FontAttributes(fa.Color, fa.Height, fa.Name, fa.Italic, fa.Bold); line.Attributes.MiddleLowerTag.Add(new TSDrg.TextElement("ya fud")); line.Modify(); //sds.Select(); //sds.Attributes.Text.Font = oldFa; //sds.Modify(); }
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(); } } } }
public void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.StraightDimensionSet) { Tekla.Structures.Drawing.StraightDimensionSet straightDim = (Tekla.Structures.Drawing.StraightDimensionSet)drawingObjectEnum.Current; if (label == "DimensionType") { straightDim.Attributes.DimensionType = dimensionType; } if (label == "DimensionUnits") { if (dimensionUnits == DimensionUnitsEnum.Automatic) { straightDim.Attributes.Format.Unit = DimensionSetBaseAttributes.DimensionValueUnits.Automatic; } else if (dimensionUnits == DimensionUnitsEnum.Centimeter) { straightDim.Attributes.Format.Unit = DimensionSetBaseAttributes.DimensionValueUnits.Centimeter; } else if (dimensionUnits == DimensionUnitsEnum.Inch) { straightDim.Attributes.Format.Unit = DimensionSetBaseAttributes.DimensionValueUnits.Inch; } else if (dimensionUnits == DimensionUnitsEnum.Meter) { straightDim.Attributes.Format.Unit = DimensionSetBaseAttributes.DimensionValueUnits.Meter; } else if (dimensionUnits == DimensionUnitsEnum.Millimeter) { straightDim.Attributes.Format.Unit = DimensionSetBaseAttributes.DimensionValueUnits.Millimeter; } } if (label == "ShortDimensionType") { if (shortDimensionType == ShortDimensionEnum.Inside) { straightDim.Attributes.ShortDimension = DimensionSetBaseAttributes.ShortDimensionTypes.Inside; } else if (shortDimensionType == ShortDimensionEnum.Outside) { straightDim.Attributes.ShortDimension = DimensionSetBaseAttributes.ShortDimensionTypes.Outside; } } if (label == "Placing") { if (placing == PlacingEnum.Fixed) { straightDim.Attributes.Placing.Placing = DimensionSetBaseAttributes.Placings.Fixed; } else if (placing == PlacingEnum.Free) { straightDim.Attributes.Placing.Placing = DimensionSetBaseAttributes.Placings.Free; } } if (label == "SearchMargin") { straightDim.Attributes.Placing.Distance.SearchMargin = double.Parse(searchMargin); } if (label == "MinimalDistance") { straightDim.Attributes.Placing.Distance.MinimalDistance = double.Parse(minimalDistance); } if (label == "PlacingDirectionPositive") { straightDim.Attributes.Placing.Direction.Positive = bool.Parse(placingDirectionPositive.ToString()); } if (label == "PlacingDirectionNegative") { straightDim.Attributes.Placing.Direction.Negative = bool.Parse(placingDirectionNegative.ToString()); } if (label == "FontColour") { straightDim.Attributes.Text.Font.Color = fontColour; } if (label == "FontHeight") { straightDim.Attributes.Text.Font.Height = double.Parse(fontHeight); } if (label == "FontName") { straightDim.Attributes.Text.Font.Name = fontName; } if (label == "FontBold") { straightDim.Attributes.Text.Font.Bold = bool.Parse(fontBold.ToString()); } if (label == "FontItalic") { straightDim.Attributes.Text.Font.Italic = bool.Parse(fontItalic.ToString()); } if (label == "Colour") { straightDim.Attributes.Color = colour; } straightDim.Modify(); drawing.CommitChanges(); } } }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.StraightDimensionSet) { Tekla.Structures.Drawing.StraightDimensionSet straightDim = (Tekla.Structures.Drawing.StraightDimensionSet)drawingObjectEnum.Current; dimensionType = straightDim.Attributes.DimensionType; if (straightDim.Attributes.ShortDimension == DimensionSetBaseAttributes.ShortDimensionTypes.Inside) { shortDimensionType = ShortDimensionEnum.Inside; } else { shortDimensionType = ShortDimensionEnum.Outside; } if (straightDim.Attributes.Format.Unit == DimensionSetBaseAttributes.DimensionValueUnits.Automatic) { dimensionUnits = DimensionUnitsEnum.Automatic; } else if (straightDim.Attributes.Format.Unit == DimensionSetBaseAttributes.DimensionValueUnits.Centimeter) { dimensionUnits = DimensionUnitsEnum.Centimeter; } else if (straightDim.Attributes.Format.Unit == DimensionSetBaseAttributes.DimensionValueUnits.Inch) { dimensionUnits = DimensionUnitsEnum.Inch; } else if (straightDim.Attributes.Format.Unit == DimensionSetBaseAttributes.DimensionValueUnits.Meter) { dimensionUnits = DimensionUnitsEnum.Meter; } else if (straightDim.Attributes.Format.Unit == DimensionSetBaseAttributes.DimensionValueUnits.Millimeter) { dimensionUnits = DimensionUnitsEnum.Millimeter; } colour = straightDim.Attributes.Color; fontName = straightDim.Attributes.Text.Font.Name; fontHeight = straightDim.Attributes.Text.Font.Height.ToString(); fontColour = straightDim.Attributes.Text.Font.Color; if (straightDim.Attributes.Text.Font.Italic) { fontItalic = Bool.True; } else { fontItalic = Bool.False; } if (straightDim.Attributes.Text.Font.Bold) { fontBold = Bool.True; } else { fontBold = Bool.False; } if (straightDim.Attributes.Placing.Placing == DimensionSetBaseAttributes.Placings.Free) { placing = PlacingEnum.Free; } else { placing = PlacingEnum.Fixed; } if (straightDim.Attributes.Placing.Direction.Negative) { placingDirectionNegative = Bool.True; } else { placingDirectionNegative = Bool.False; } if (straightDim.Attributes.Placing.Direction.Positive) { placingDirectionPositive = Bool.True; } else { placingDirectionPositive = Bool.False; } minimalDistance = straightDim.Attributes.Placing.Distance.MinimalDistance.ToString(); searchMargin = straightDim.Attributes.Placing.Distance.SearchMargin.ToString(); } } } else if (drawingObjectEnum.GetSize() > 1) { dimensionType = new DimensionSetBaseAttributes.DimensionTypes(); shortDimensionType = new ShortDimensionEnum(); dimensionUnits = new DimensionUnitsEnum(); colour = new DrawingColors(); fontName = ""; fontHeight = ""; fontColour = new DrawingColors(); fontItalic = new Bool(); fontBold = new Bool(); placing = new PlacingEnum(); placingDirectionNegative = new Bool(); placingDirectionPositive = new Bool(); minimalDistance = ""; searchMargin = ""; } }
public _StraightDimentionSet(TSD.StraightDimensionSet obj) { _set = obj as TSD.StraightDimensionSet; _points = new TSD.PointList(); getDimSetPoints(); }
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); } }