private void InsertBlock() { using (var a = new GetDimensions()) { MathPoint instancePosition; if (_swModel.Extension.SelectByID2("Точка вставки/" + a.CreateBlock(_swApp, _holeType, out instancePosition), "SKETCHPOINT", 0, 0, 0, true, 0, null, 0) && _ent.Select(true)) _swModel.SketchAddConstraints("sgCONCENTRIC"); _swModel.ClearSelection(); } }
private static Common AnalizViewCoefficient(ModelDoc2 swModel, double[] boundBox,ref BlockPosition side, out double[] dimLinDirH, out double[] dimLinDirV, out bool? blockSize,out Ordinate vertex,out Ordinate vertexS,double[] dsDim,double[] deDim,double[] endDim,string dsName,string deName) { double x, y; Annotation annX, annY; using (var a = new GetDimensions()) { bool consider; var tmpSide = GetDimensions.GetBlockPosition(swModel, out consider);//a.GetBlockPosition(swModel,out consider); if (consider) // consider -принимать ли в расчет tmpSide side = tmpSide; dimLinDirH = a.GetDimensionLineDirect(swModel, boundBox, false, side, out x, out annX, out blockSize,out vertex,out vertexS,dsDim,deDim,endDim,dsName,deName); } using (var a = new GetDimensions()) { Ordinate vert, verts; dimLinDirV = a.GetDimensionLineDirect(swModel, boundBox, true, side, out y, out annY, out blockSize, out vert, out verts, dsDim, deDim, endDim, dsName, deName); if (verts != null) vertexS = verts; } return new Common(new Coord(new CoordX(x, annX), new CoordY(y, annY)), null); }
private bool FoundParamsOfCuvites(out Annotation annH, out DisplayDimension swDispDimH) { bool ret = false; annH = null; var swDrawing = (DrawingDoc)_swModel; int i = 0; do { using (var a = new GetDimensions()) { swDispDimH = a.GetDisplayDim(swDrawing, _ent, _swSelData); } i++; } while (swDispDimH == null && i < 3); if (swDispDimH != null) { var dimObjH = (Dimension)swDispDimH.GetDimension(); string holeDepSuffix = swDispDimH.GetText((int)swDimensionTextParts_e.swDimensionTextPrefix); if (dimObjH != null) { double diam = Convert.ToDouble(Strings.Left(holeDepSuffix, 1) == "R" ? (dimObjH.Value * 2).ToString("0.00") : (dimObjH.Value).ToString("0.00")); var holeDepSuffix1 = swDispDimH.GetText((int)swDimensionTextParts_e.swDimensionTextSuffix); if (string.IsNullOrEmpty(holeDepSuffix1) && !string.IsNullOrEmpty(holeDepSuffix)) { var tt =holeDepSuffix.Split(new string[1]{"<HOLE-DEPTH>"},5,StringSplitOptions.RemoveEmptyEntries); if (tt.Length>=2) holeDepSuffix1 = "<HOLE-DEPTH> " + tt[1]; } double depth; try { string holeDepSuffixAbridgement = Strings.Right(holeDepSuffix1, holeDepSuffix1.Length - 12); depth = Convert.ToDouble(holeDepSuffixAbridgement.Replace('.', ',')); } catch { try { string holeDepSuffixAbridgement = Strings.Right(holeDepSuffix1, holeDepSuffix1.Length - 12); depth = Convert.ToDouble(holeDepSuffixAbridgement); } catch { depth = 0; } } int drType = 7; var swView = swDrawing.IActiveDrawingView; if (swView != null) drType = swView.Type; bool type = drType == 4; var diamAndDepth = SetManualDiametrAndDepth(diam, depth, type); if (_doThroughHoles || diamAndDepth.Y != 0)//if (_side.AsBoolean() || diamAndDepth.Y != 0) // насколько я понимаю, только этот if определяет, указывать ли сквознае отверстия { StrType = GetStringHoleType(diamAndDepth.X, diamAndDepth.Y); _holeType = DefinitionHolesType(diamAndDepth.X, diamAndDepth.Y); annH = swDispDimH.IGetAnnotation(); ret = true; } else { swDispDimH.IGetAnnotation().Select(true); _swModel.DeleteSelection(true); } } } _swModel.ClearSelection(); return ret; }
private void LegendMaker(ModelDoc2 swModel, DrawingDoc swDraw, IEnumerable<string> type, double vScaleRatio) { foreach (var t in type) { using (var a = new GetDimensions()) { MathPoint instancePosition; if (t.Contains("8h") && t.StartsWith("8h")) { a.CreateBlock(_swApp, 2, out instancePosition, 1.45 / 15 * vScaleRatio, 0.134 / 15 * vScaleRatio); AddTextBlock(swModel, swDraw, "- отв." + "<MOD-DIAM>" + "8 несквозные", 0.1, 0.011, 0, 0.0025, 0, instancePosition,true); } if (t == "5h12") { a.CreateBlock(_swApp, 1, out instancePosition, 0.36 / 15 * vScaleRatio, 0.134 / 15 * vScaleRatio); AddTextBlock(swModel, swDraw, "- отв." + "<MOD-DIAM>" + "5h12", 0.027, 0.011, 0, 0.0025, 0, instancePosition,true); } if (t == "8") { a.CreateBlock(_swApp, 3, out instancePosition, 2.09 / 15 * vScaleRatio, 0.134 / 15 * vScaleRatio); AddTextBlock(swModel, swDraw, "- отв." + "<MOD-DIAM>" + "8 сквозные", 0.142, 0.011, 0, 0.0025, 0, instancePosition,true); } if (t == "5") { a.CreateBlock(_swApp, 0, out instancePosition, 0.85 / 15 * vScaleRatio, 0.134 / 15 * vScaleRatio); AddTextBlock(swModel, swDraw, "- отв." + "<MOD-DIAM>" + "5" + " сквозные", 0.06, 0.011, 0, 0.0025, 0, instancePosition,true); } if (t.Contains("8.11")) { a.CreateBlock(_swApp, 4, out instancePosition, 0.36 / 15 * vScaleRatio, 0.224 / 15 * vScaleRatio); AddTextBlock(swModel, swDraw, "- отв." + "<MOD-DIAM>" + "8h22", 0.027, 0.017, 0, 0.0025, 0, instancePosition,true); } } } }