public override void OnDraw(GeometryBuilder dc) { dc.Clear(); dc.Color = McDbEntity.ByObject; Polyline3d poly = new Polyline3d(new List <Point3d> { _pnt, _pnt1, _pnt2, _pnt3, _pnt }); Polyline3d poly_offset = poly.GetTrimmedOffset(-Width)[0]; dc.DrawPolyline(poly); dc.DrawPolyline(poly_offset); dc.DrawLine(_pnt, poly_offset.Points[0]); dc.DrawLine(_pnt1, poly_offset.Points[1]); dc.DrawLine(_pnt2, poly_offset.Points[2]); dc.DrawLine(_pnt3, poly_offset.Points[3]); if (Thickness != 0) { dc.DrawPolyline(poly.GetTrimmedOffset(-Width / 2 + Thickness / 2)[0]); dc.DrawPolyline(poly.GetTrimmedOffset(-Width / 2 + -Thickness / 2)[0]); } }
public override void OnDraw(GeometryBuilder dc) { dc.Clear(); dc.Color = McDbEntity.ByObject; Polyline3d poly = new Polyline3d(new List <Point3d> { _pnt1, _pnt2 }); double gap = Thickness < 0 ? Gap * -1 : Gap; poly = _Inside ? poly.GetTrimmedOffset(Offset - gap)[0] : poly; ConShape shape = new ConShape(poly.Points.FirstPoint, poly.Points.LastPoint, Thickness + gap * (_Inside ? 2 : 1), Length + Gap * 2, Margin - Gap, Count); for (int i = 1; i < Count + 1; i++) { dc.DrawPolyline(shape.polyline(i, _Inside)); } }
public override void OnDraw(GeometryBuilder dc) { dc.Clear(); dc.Color = McDbEntity.ByObject;//color will be taken from object properties and object will be redrawn after color change if (V_true == 0) { double pos_thickness = Thickness < 0 ? Thickness * -1 : Thickness; if (pos_thickness < 3) { V = 16; } else if (pos_thickness == 3) { V = 20; } else if (pos_thickness == 4) { V = 35; } else if (pos_thickness > 4) { V = 50; } } else { V = V_true; } Polyline3d polyround = new Polyline3d(poly); _length_sum = 0; //HostMgd.EditorInput.Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; for (int i = 2; i < polyround.Vertices.Count; i += 2) { //double angle1 = Math.Atan2(polyround.Vertices[i - 2].Point.X - polyround.Vertices[i - 1].Point.X, polyround.Vertices[i - 2].Point.Y - polyround.Vertices[i - 1].Point.Y); //double angle2 = Math.Atan2(polyround.Vertices[i - 1].Point.X - polyround.Vertices[i].Point.X, polyround.Vertices[i - 1].Point.Y - polyround.Vertices[i].Point.Y); double anglesum = (polyround.Vertices[i - 1].Point.X - polyround.Vertices[i].Point.X) * (polyround.Vertices[i - 2].Point.Y - polyround.Vertices[i].Point.Y) - (polyround.Vertices[i - 1].Point.Y - polyround.Vertices[i].Point.Y) * (polyround.Vertices[i - 2].Point.X - polyround.Vertices[i].Point.X);//Math.Atan((angle2 - angle1) / (1 + angle2 * angle1));//angle1 + angle2 double a = polyround.Vertices[i - 2].Point.DistanceTo(polyround.Vertices[i - 1].Point); double b = polyround.Vertices[i - 1].Point.DistanceTo(polyround.Vertices[i].Point); double c = polyround.Vertices[i - 2].Point.DistanceTo(polyround.Vertices[i].Point); double angle = Math.Acos((Math.Pow(a, 2) + Math.Pow(b, 2) - Math.Pow(c, 2)) / (2 * a * b)); angle = angle * 180 / Math.PI; double r = V * 0.16; double pos_thickness = Thickness < 0 ? Thickness * -1 : Thickness; double BA = Math.PI / 180 * (180 - angle) * (r + k_factor * pos_thickness); _length_sum += BA; double radius; if (anglesum < 0) { radius = V * 0.16; } else { radius = V * 0.16 + Thickness; } if (Thickness < 0) { radius += Thickness * -1; } polyround.Vertices.MakeFilletAtVertex(i - 1, radius); } for (int i = 0; i < polyround.Vertices.Count; i += 2) { LineSeg3d line = polyround.Segments[i] as LineSeg3d; _length_sum += line.Length; } _length_sum = Math.Round(_length_sum, 4); Polyline3d offset = polyround.GetTrimmedOffset(-Thickness)[0]; dc.DrawPolyline(polyround); dc.DrawPolyline(offset); dc.DrawLine(polyround.Points.FirstPoint, offset.Points.FirstPoint); dc.DrawLine(polyround.Points.LastPoint, offset.Points.LastPoint); Polyline3d middlePoly = polyround.GetTrimmedOffset(-Thickness * (Thickness < 0 ? 1 - k_factor : k_factor))[0]; dc.TextHeight = 2.5 * DbEntity.Scale; //Use annotation scale dc.DrawMText(_textPoint, Vector3d.XAxis, Math.Round(_length_sum, 1).ToString(), HorizTextAlign.Center, VertTextAlign.Center); dc.StrLineType = "Center"; dc.Color = Color.Yellow; dc.LinetypeScale = DbEntity.LinetypeScale * 0.3; dc.DrawPolyline(middlePoly); }