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 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(); } } }