Example #1
0
        static public SketchLine midleLine(SketchLine sl1, SketchLine sl2)
        {
            PlanarSketch       ps  = (PlanarSketch)sl1.Parent;
            SketchPoint        sp1 = ps.SketchPoints.Add(sl1.Geometry.MidPoint, false);
            SketchPoint        sp2 = ps.SketchPoints.Add(sl2.Geometry.MidPoint, false);
            SketchLine         sl3 = ps.SketchLines.AddByTwoPoints(sp1, sp2);
            MidpointConstraint mpc = ps.GeometricConstraints.AddMidpoint(sp1, sl1);

            mpc = ps.GeometricConstraints.AddMidpoint(sp2, sl2);
            sl3.Construction = true;
            return(sl3);
        }
Example #2
0
        static public void offsetAdaptive(SheetMetalComponentDefinition smcd, string name, double valA, double valB, double valB1)
        {
            double       a = valA, b = valB;
            PlanarSketch ps        = smcd.Sketches[name];
            PlanarSketch newSketch = smcd.Sketches.Add(ps.PlanarEntity);

            name = newSketch.Name;
            Profile profiles = ps.Profiles.AddForSolid();

            foreach (ProfilePath pr in profiles)
            {
                bool flag = cmpLen(pr, valB1 - 0.03);
                if (flag)
                {
                    b = valB1;/*Convert.ToDouble(this.textBox3.Text.Replace(',', separator)) / 10;*/
                }
                if (pr.Count == 4)
                {
                    ProfileEntity pe1 = (ProfileEntity)pr[1];
                    ProfileEntity pe3 = (ProfileEntity)pr[3];
                    if (pe1.CurveType != Curve2dTypeEnum.kLineSegmentCurve2d || pe1.EndSketchPoint.Geometry.DistanceTo(pe1.StartSketchPoint.Geometry) > valA * 2)
                    {
                        pe1 = (ProfileEntity)pr[2]; pe3 = (ProfileEntity)pr[4];
                    }
                    //pe1.SketchEntity.Construction = true;

                    //ProfileEntity pe1 = pr.OfType<ProfileEntity>().FirstOrDefault(e1 => e1.CurveType == Curve2dTypeEnum.kLineCurve2d &&
                    //    (e1.EndSketchPoint.Geometry.DistanceTo(e1.StartSketchPoint.Geometry) <= 0.1));
                    //ProfileEntity pe3 = pr.OfType<ProfileEntity>().LastOrDefault(e1 => e1.CurveType == Curve2dTypeEnum.kLineCurve2d &&
                    //    (e1.EndSketchPoint.Geometry.DistanceTo(e1.StartSketchPoint.Geometry) <= 0.1));
                    if (pe1 == null || pe3 == null)
                    {
                        continue;
                    }


                    //SketchLine sl1 = (SketchLine)pe1.SketchEntity;
                    //SketchLine sl2 = (SketchLine)pe3.SketchEntity;

                    SketchLine sl1 = (SketchLine)newSketch.AddByProjectingEntity(pe1.SketchEntity);
                    SketchLine sl2 = (SketchLine)newSketch.AddByProjectingEntity(pe3.SketchEntity);

                    //sl2.Construction = true;
                    SketchLine         sl3 = midleLine(sl1, sl2);
                    SketchPoint        mp  = newSketch.SketchPoints.Add(sl3.Geometry.MidPoint, false);
                    MidpointConstraint mpc = newSketch.GeometricConstraints.AddMidpoint(mp, sl3);
                    //SketchBlock sb;
                    //SketchLine newLin;
                    //if (b == valB)
                    //{
                    //    sb = ps.SketchBlocks.AddByDefinition(smcd.SketchBlockDefinitions["Паз"], mp.Geometry);
                    //}
                    //else
                    //{
                    //    sb = ps.SketchBlocks.AddByDefinition(smcd.SketchBlockDefinitions["Паз_замыкающий"], mp.Geometry);
                    //}
                    //    newLin = ps.SketchLines.OfType<SketchLine>().LastOrDefault(l => l.Construction == true);
                    //    ps.GeometricConstraints.AddCollinear((SketchEntity)newLin, (SketchEntity)sl3);

                    rect(sl3, mp, a, b);
                }
            }
            //foreach (SketchBlock item in ps.SketchBlocks)
            //{
            //    item.Explode();
            //}
            //foreach (DimensionConstraint item in newSketch.DimensionConstraints)
            //{
            //    item.Delete();
            //}
            //addEqualLength(newSketch, valA);
            //addEqualLength(newSketch, valB);
            //addEqualLength(newSketch, valB1);

            CutFeature cut = addCut(smcd, name); cut.Name = "Пазы";
        }