public void ConstructToolpathObject(ProcessObject obj) { if (obj.Side == SideType.None) { return; } if (ProcessOptions.Machine == ProcessOptions.TTypeMachine.Ravelli) { ConstructToolpathObjectRavelli(obj); return; } if (obj.ObjectType == ObjectType.Arc && ( (obj.ProcessArc.StartAngle < cPI2 && obj.ProcessArc.EndAngle > cPI2) || (obj.ProcessArc.StartAngle < cPI + cPI2 && (obj.ProcessArc.EndAngle > cPI + cPI2 || obj.ProcessArc.EndAngle < obj.ProcessArc.StartAngle)))) { Application.ShowAlertDialog("Обработка дуги невозможна - дуга пересекает угол 90 или 270 градусов. Текущие углы: начальный " + (180 / cPI * obj.ProcessArc.StartAngle).ToString() + ", конечный " + (180 / cPI * obj.ProcessArc.EndAngle).ToString()); //Application.ShowAlertDialog($"Обработка дуги {obj} невозможна - дуга пересекает угол 90 или 270 градусов. Текущие углы: начальный {180 / cPI * obj.ProcessArc.StartAngle}, конечный {180 / cPI * obj.ProcessArc.EndAngle}"); return; } double s = Math.Sqrt(obj.DepthAll * (obj.Diameter - obj.DepthAll)) + ExactlyIncrease; if ((obj.IsBeginExactly || obj.IsEndExactly) && (obj.Length <= s)) { Application.ShowAlertDialog("Обработка объекта " + obj.ToString() + " невозможна вследствие слишком малой длины"); return; } Curve toolpathCurve = obj.ProcessCurve.GetOffsetCurves(GetOffsetValue(obj))[0] as Curve; // TODO расчет OffsetCurves + ModifiedEventHandler switch (obj.ObjectType) { case ObjectType.Line: if (obj.IsBeginExactly) { toolpathCurve.StartPoint = toolpathCurve.GetPointAtDist(s); } if (obj.IsEndExactly) { toolpathCurve.EndPoint = toolpathCurve.GetPointAtDist((toolpathCurve as Line).Length - s); } break; case ObjectType.Arc: if (obj.IsBeginExactly) { (toolpathCurve as Arc).StartAngle = obj.ProcessArc.StartAngle + s / obj.ProcessArc.Radius; } if (obj.IsEndExactly) { (toolpathCurve as Arc).EndAngle = obj.ProcessArc.EndAngle - s / obj.ProcessArc.Radius; } break; } using (DocumentLock doclock = Document.LockDocument()) { using (AcDb.Transaction trans = TransactionManager.StartTransaction()) { if (obj.ToolpathCurve == null) // TODO удаление объекта { BlockTable BlkTbl = trans.GetObject(Database.BlockTableId, OpenMode.ForRead, false) as BlockTable; BlockTableRecord BlkTblRec = trans.GetObject(BlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false) as BlockTableRecord; toolpathCurve.LayerId = GetProcessLayer(trans); BlkTblRec.AppendEntity(toolpathCurve); trans.AddNewlyCreatedDBObject(toolpathCurve, true); toolpathCurve.Erased += new ObjectErasedEventHandler(ToolpathCurveErasedEventHandler); obj.ToolpathCurve = toolpathCurve; } else { trans.GetObject(obj.ToolpathCurve.ObjectId, AcDb.OpenMode.ForWrite); switch (obj.ObjectType) { // TODO копия объекта case ObjectType.Line: obj.ToolpathCurve.StartPoint = toolpathCurve.StartPoint; obj.ToolpathCurve.EndPoint = toolpathCurve.EndPoint; break; case ObjectType.Arc: (obj.ToolpathCurve as Arc).Center = (toolpathCurve as Arc).Center; (obj.ToolpathCurve as Arc).Radius = (toolpathCurve as Arc).Radius; (obj.ToolpathCurve as Arc).StartAngle = (toolpathCurve as Arc).StartAngle; (obj.ToolpathCurve as Arc).EndAngle = (toolpathCurve as Arc).EndAngle; break; } } trans.Commit(); Editor.UpdateScreen(); } } }
public void addProcess(ProcessObject processObject) { m_processList.Add(processObject); fmObject.AddItem(processObject.ToString()); }