/// <summary> /// Метод копирует последнюю операцию /// по концентрической окружности относительно оси OY /// </summary> /// <param name="count">Количество копий</param> public bool CreateOperationCircPartArray(int count) { try { ksEntityCollection elemCol = (ksEntityCollection)_app.Part.EntityCollection((short)Obj3dType.o3d_cutExtrusion); if ((elemCol != null) && (elemCol.GetCount() != 0)) { ksEntity axis = (ksEntity)_app.Part.NewEntity((short)Obj3dType.o3d_axisOY); ksEntity circCopy = (ksEntity)_app.Part.NewEntity((short)Obj3dType.o3d_circularCopy); ksCircularCopyDefinition CopyDef = (ksCircularCopyDefinition)circCopy.GetDefinition(); if (CopyDef != null) { CopyDef.count1 = 1; CopyDef.count2 = count; CopyDef.step2 = 360; CopyDef.factor2 = true; CopyDef.SetAxis(axis); ksEntityCollection copiedElemCol = (ksEntityCollection)CopyDef.GetOperationArray(); copiedElemCol.Clear(); int i = elemCol.GetCount(); copiedElemCol.Add(elemCol.GetByIndex(i - 1)); circCopy.Create(); } } return(true); } catch { return(false); } }
/// <summary> /// Метод выполняет операцию выдавливания /// для последнего созданного эскиза /// </summary> /// <param name="depth">Глубина выдавливания</param> public bool DoOperationExtrusion(double depth) { try { ksEntityCollection coll = (ksEntityCollection)_app.Part.EntityCollection((short)Obj3dType.o3d_sketch); int i = coll.GetCount(); ksEntity sketch = coll.GetByIndex(i - 1); ksEntity entityExtr = (ksEntity)_app.Part.NewEntity((short)Obj3dType.o3d_baseExtrusion); if (entityExtr != null) { ksBaseExtrusionDefinition extrusionDef = (ksBaseExtrusionDefinition)entityExtr.GetDefinition(); if (extrusionDef != null) { extrusionDef.directionType = (short)Direction_Type.dtMiddlePlane; } extrusionDef.SetSideParam(true, (short)End_Type.etBlind, depth); extrusionDef.SetSketch(sketch); entityExtr.Create(); entityExtr.Update(); } return(true); } catch { return(false); } }
/// <summary> /// создание фаски /// </summary> /// <param name="param"></param> public void CreateChamfer(Parameters param) { double Lenght1 = param.Lenght1; double Lenght2 = param.Lenght2; double Angle1 = param.Angle1; var doc = (ksDocument3D)_kompas.ActiveDocument3D(); ksPart part2 = (ksPart)doc.GetPart((short)Part_Type.pTop_Part); // новый компонент if (part2 != null) { ksEntityCollection collect2 = (ksEntityCollection)part2.EntityCollection((short)Obj3dType.o3d_face); if (collect2 != null && collect2.SelectByPoint(0, 0, Lenght1 + 5 + Lenght2) && collect2.GetCount() != 0) { ksEntity entityChamfer = (ksEntity)part2.NewEntity((short)Obj3dType.o3d_chamfer); if (entityChamfer != null) { ksChamferDefinition ChamferDef = (ksChamferDefinition)entityChamfer.GetDefinition(); if (ChamferDef != null) { ChamferDef.tangent = false; ChamferDef.SetChamferParam(true, Angle1, Angle1); ksEntityCollection arr = (ksEntityCollection)ChamferDef.array(); // динамический массив объектов if (arr != null) { for (int i = 0, count = collect2.GetCount(); i < count; i++) { arr.Add(collect2.GetByIndex(i)); } entityChamfer.Create(); } } } } } }
public override ksEntity Execute() { _extrudeHandleCmd.Execute(); ksEntity fillet = Part.NewEntity((short)Obj3dType.o3d_fillet); ksFilletDefinition filletDefinition = fillet.GetDefinition(); filletDefinition.radius = 1; filletDefinition.tangent = false; ksEntityCollection facesToFillet = filletDefinition.array(); facesToFillet.Clear(); ksEntityCollection partFaces = Part.EntityCollection((short)Obj3dType.o3d_face); for (int i = 0; i < partFaces.GetCount(); i++) { facesToFillet.Add(partFaces.GetByIndex(i)); } fillet.Create(); return(fillet); }
/// <summary> /// Метод создает фаску в 45' /// </summary> public bool Create(double dist, Point3d coor) { try { ksEntityCollection edge = (ksEntityCollection)_app.Part.EntityCollection((short)Obj3dType.o3d_edge); if ((edge != null) && (edge.SelectByPoint(coor.X, coor.Y, coor.Z)) && (edge.GetCount() != 0)) { ksEntity chamfer = (ksEntity)_app.Part.NewEntity((short)Obj3dType.o3d_chamfer); ksChamferDefinition chDef = (ksChamferDefinition)chamfer.GetDefinition(); if (chDef != null) { chDef.tangent = true; chDef.SetChamferParam(false, dist, dist); ksEntityCollection chamferCollection = (ksEntityCollection)chDef.array(); chamferCollection.Clear(); chamferCollection.Add(edge.GetByIndex(0)); chamfer.Create(); } } return(true); } catch { return(false); } }