Ejemplo n.º 1
0
        public override void BuildProcessing(MillingCommandGenerator generator)
        {
            var railBase    = TechProcess.Rail?.GetCurve() ?? new Line(Point3d.Origin, Point3d.Origin + Vector3d.XAxis * TechProcess.Length.Value);
            var profile     = (Profile ?? TechProcess.ProcessingArea[0]).GetCurve();
            var processSide = ChangeEngineSide ? -1 : 1;

            CreateProfile3D(profile, railBase, 1);
            //var processSide = ChangeProcessSide ? -1 : 1;
            //CreateProfile3D(profile, railBase, processSide);

            var rail = CreateDepartureRail(railBase, Departure);

            if (Delta != 0)
            {
                var profileOffset = (Curve)profile.GetOffsetCurves(Delta)[0];
                profile = profileOffset.EndPoint.GetAsVector().Length < profile.EndPoint.GetAsVector().Length
                    ? (Curve)profile.GetOffsetCurves(-Delta)[0]
                    : profileOffset;
                CreateProfile3D(profile, railBase, processSide);
            }
            if (!(railBase is Line))
            {
                processSide *= -1;
            }
            if (railBase.IsNewObject)
            {
                railBase.Dispose();
            }

            var side = BuilderUtils.CalcEngineSide(rail.GetFirstDerivative(0).GetAngleTo(Vector3d.XAxis));

            if (ChangeEngineSide)
            {
                side = SideExt.Opposite(side);
            }
            var isMinToolCoord = IsA90
                ? TechProcess.MachineType.Value != MachineType.ScemaLogic
                : side == Side.Right ^ TechProcess.MachineType.Value == MachineType.ScemaLogic ^ ChangeProcessSide;

            generator.CuttingFeed = CuttingFeed;
            generator.SmallFeed   = TechProcess.PenetrationFeed;
            generator.EngineSide  = side;

            Curve outletCurve = null;

            if (IsA90 && IsOutlet)
            {
                outletCurve = rail.GetOffsetCurves(TechProcess.ZSafety * processSide)[0] as Curve;
                var angleC = BuilderUtils.CalcToolAngle(outletCurve, outletCurve.StartPoint, side);
                generator.Move(outletCurve.StartPoint.X, outletCurve.StartPoint.Y, angleC: angleC, angleA: 90);
            }
            var angleA = IsA90 ? 90 : 0;
            var index  = IsA90 ? 1 : 0;

            var points = BuilderUtils.GetProcessPoints(profile, index, StepPass, TechProcess.Tool.Thickness.Value, isMinToolCoord, FirstPass, LasttPass, IsExactlyBegin, IsExactlyEnd, IsProfileStep);

            foreach (var point in points)
            {
                var end   = Math.Max(point[1 - index], PenetrationEnd ?? double.MinValue);
                var count = 1;
                var penetrationStepCalc = 0D;
                if (PenetrationStep.GetValueOrDefault() > 0 && PenetrationBegin.GetValueOrDefault() > end)
                {
                    var allPenetration = PenetrationBegin.Value - end;
                    count = (int)Math.Ceiling(allPenetration / PenetrationStep.Value);
                    penetrationStepCalc = allPenetration / count;
                }
                if (IsA90 && IsOutlet && generator._isEngineStarted)
                {
                    generator.Transition(z: point[index]);
                }

                var coords = Enumerable.Range(1, count).Select(p => end + (count - p) * penetrationStepCalc).ToList();
                if (IsA90)
                {
                    coords.ForEach(p => generator.Cutting(rail, processSide * p, point[index], angleA: angleA));
                }
                else
                {
                    coords.ForEach(p => generator.Cutting(rail, processSide * point[index], p, angleA: angleA));
                }

                if (IsOutlet)
                {
                    if (IsA90)
                    {
                        var pt = outletCurve.GetClosestPoint(generator.ToolPosition.Point);
                        generator.Move(pt.X, pt.Y);
                    }
                    else
                    {
                        generator.Uplifting();
                    }
                }
            }
            rail.Dispose();
        }
Ejemplo n.º 2
0
        public override void BuildProcessing(MillingCommandGenerator generator)
        {
            var railBase    = TechProcess.Rail?.GetCurve() ?? new Line(Point3d.Origin, Point3d.Origin + Vector3d.XAxis * TechProcess.Length.Value);
            var profile     = (Profile ?? TechProcess.ProcessingArea[0]).GetCurve();
            var processSide = ChangeProcessSide ? 1 : -1;

            CreateProfile3D(profile, railBase, processSide);

            var rail = CreateDepartureRail(railBase, Departure);

            if (Delta != 0)
            {
                var profileOffset = (Curve)profile.GetOffsetCurves(Delta)[0];
                profile = profileOffset.EndPoint.GetAsVector().Length < profile.EndPoint.GetAsVector().Length
                    ? (Curve)profile.GetOffsetCurves(-Delta)[0]
                    : profileOffset;
                CreateProfile3D(profile, railBase, processSide);
            }
            var offsetSign = processSide * (railBase is Line ? 1 : -1);

            if (railBase.IsNewObject)
            {
                railBase.Dispose();
            }

            var side = BuilderUtils.CalcEngineSide(rail.GetFirstDerivative(0).GetAngleTo(Vector3d.XAxis));

            if (ChangeEngineSide)
            {
                side = SideExt.Opposite(side);
            }
            var isMinToolCoord = IsA90
                ? TechProcess.MachineType.Value != MachineType.ScemaLogic
                : side == Side.Right ^ TechProcess.MachineType.Value == MachineType.ScemaLogic ^ ChangeProcessSide;

            generator.CuttingFeed = CuttingFeed;
            generator.SmallFeed   = TechProcess.PenetrationFeed;
            generator.EngineSide  = side;

            Curve outletCurve = null;

            if (IsA90 && IsOutlet)
            {
                outletCurve = rail.GetOffsetCurves(TechProcess.ZSafety * offsetSign)[0] as Curve;
                var angleC = BuilderUtils.CalcToolAngle(outletCurve, outletCurve.StartPoint, side);
                generator.Move(outletCurve.StartPoint.X, outletCurve.StartPoint.Y, angleC: angleC, angleA: 90);
            }
            var angleA = IsA90 ? 90 : 0;
            var index  = IsA90 ? 1 : 0;

            var profilePoints = BuilderUtils.GetProcessPoints(profile, index, ProfileStep, TechProcess.Tool.Thickness.Value, isMinToolCoord, ProfileBegin, ProfileEnd, IsExactlyBegin, IsExactlyEnd, true);

            var profilePline = new Polyline();

            Enumerable.Range(0, profilePoints.Count).ForEach(i => profilePline.AddVertexAt(i, profilePoints[i], 0, 0, 0));

            var railLength = rail.Length();

            Acad.SetLimitProgressor((int)(railLength / LongStep));

            for (double dist = 0; dist < railLength; dist += LongStep)
            {
                Acad.ReportProgressor();

                var point     = rail.GetPointAtDist(dist);
                var angleC    = BuilderUtils.CalcToolAngle(rail, point, side);
                var passPline = CalcPassPline(rail, point, profilePline, processSide);

                generator.Cutting(passPline, CuttingFeed, TechProcess.PenetrationFeed, angleC: angleC, angleA: angleA);

                if (IsOutlet)
                {
                    if (IsA90)
                    {
                        var pt = outletCurve.GetClosestPoint(generator.ToolPosition.Point);
                        generator.Move(pt.X, pt.Y);
                    }
                    else
                    {
                        generator.Uplifting();
                    }
                }
            }
            rail.Dispose();
        }