public void addDimConstr(SketchPoint p, SketchLine sl, Parameter par = null)
        {
            Vector2d v = ut.normal(sl.StartSketchPoint.Geometry, sl.EndSketchPoint.Geometry), v1 = p.Geometry.VectorTo(sl.StartSketchPoint.Geometry);

            if (v.AngleTo(v1) > Math.PI / 2)
            {
                v.ScaleBy(-1);
            }
            pt = p.Geometry.Copy();
            pt.TranslateBy(v);
            ObjectsEnumerator en = sl.Geometry.IntersectWithCurve(I.tg.CreateLineSegment2d(p.Geometry, pt), 0.1);

            if (en != null && en.Count != 0)
            {
                pt = en[1] as Point2d;
            }
            OffsetDimConstraint offs = ps.DimensionConstraints.AddOffset(sl, p as SketchEntity, ut.midPt(p.Geometry, pt, p.Geometry.DistanceTo(pt) / 5, 0), false);

            if (par != null)
            {
                offs.Parameter.Expression = par.Name;
            }
            else
            {
                offs.Parameter.Value = 0;
            }
        }
        public SketchPoint addPoint(SketchLine sl1, SketchLine sl2)
        {
            Vector2d v1 = addVec(sp, sl1), v2 = addVec(sp, sl2);

            pt = sp.Geometry.Copy();
            v1.AddVector(v2);
            v1.ScaleBy(0.4);
            pt.TranslateBy(v1);
            return(ps.SketchPoints.Add(pt));
        }
        public SketchLine addPerpendicular(SketchLine line, SketchLine dir, SketchLine sl = null)
        {
            vec = addVec(sp, dir);
            vec.ScaleBy(0.5);
            pt = line.Geometry.MidPoint;
            pt.TranslateBy(vec);
            SketchLine l;

            if (sl == null)
            {
                l = ps.SketchLines.AddByTwoPoints(line.Geometry.MidPoint as object, pt as object);
            }
            else
            {
                l = ps.SketchLines.AddByTwoPoints(line.Geometry.MidPoint, sl.EndSketchPoint);
            }
            l.Construction = true;
            addMidConsraint(line, l);
            ps.GeometricConstraints.AddParallel(l as SketchEntity, dir as SketchEntity);
            return(l);
        }