Exemplo n.º 1
0
        /// <summary>
        /// Расчет обработки
        /// </summary>
        public static List <ProcessingAction> Generate(IEnumerable <ProcessObject> processObjects, List <Curve> sectionCurves)
        {
            try
            {
                IsCalculation = true;
                AutocadUtils.StartTransaction();
                Machine.Start();
                foreach (var processObject in processObjects)
                {
                    if (!IsCalculation)
                    {
                        break;
                    }
                    if (!CheckParams(processObject))
                    {
                        continue;
                    }

                    Machine.SetTool(processObject.Tool);

                    if (processObject.Curve.OutsideSign == 0)
                    {
                        CalcUtils.CalcOutside(processObject.Curve);
                    }

                    var curve = AutocadUtils.GetCurve(processObject.Curve.ObjectId);

                    if (Settings.ProcessMode == ProcessMode.ContinuousDescent)
                    {
                        if (!curve.Closed)
                        {
                            throw new Exception("Расчет в режиме непрерывного опускания возможен только для замкнутой кривой");
                        }
                        CuttingContinuousDescent(processObject, curve);
                    }
                    else if (Settings.ProcessMode == ProcessMode.ProfileDisc)
                    {
                        CuttingProfileDisc(processObject, curve, sectionCurves);
                    }
                    else
                    {
                        Cutting(processObject, curve);
                    }
                }
                Machine.Stop();
                AutocadUtils.CommitTransaction();
            }
            catch (Exception e)
            {
                Machine.Clear();
                var error = String.Format("Ошибка при расчете обработки: {0}", e.Message);
                AutocadUtils.ShowError(error);
            }
            AutocadUtils.DisposeTransaction();
            IsCalculation = false;

            return(Machine.GetProcessingActions());
        }