/// <summary> /// Метод для создание массива шариков по концентрической сетке /// </summary> /// <param name="part">деталь</param> /// <param name="sketch">Эскиз</param> /// <param name="type">направлние</param> /// <param name="planeXOZ">плоскость XOZ</param> /// <param name="planeYOZ">плоскость YOZ</param> private static void BallsConcentricArray(ksPart part, ksEntity sketch, short type, ksEntity planeXOZ, ksEntity planeYOZ) { ksEntity rotate = part.NewEntity((short)Obj3dType.o3d_bossRotated); ksBossRotatedDefinition rotDef = rotate.GetDefinition(); rotDef.directionType = type; rotDef.SetSketch(sketch); rotDef.SetSideParam(true, 360); ksRotatedParam rotateParam = rotDef.RotatedParam(); rotate.Create(); //ОСЬ ksEntity axis = part.NewEntity((short)Obj3dType.o3d_axis2Planes); ksAxis2PlanesDefinition axisdef = axis.GetDefinition(); axisdef.SetPlane(1, planeXOZ); axisdef.SetPlane(2, planeYOZ); axis.Create(); //Массив по Кругу ksEntity circrotate = part.NewEntity((short)Obj3dType.o3d_circularCopy); ksCircularCopyDefinition cpyRotDef = circrotate.GetDefinition(); cpyRotDef.SetAxis(axis); cpyRotDef.SetCopyParamAlongDir(8, 45, false, false); EntityCollection circcoll = (cpyRotDef.GetOperationArray()); circcoll.Clear(); circcoll.Add(rotate); circrotate.Create(); }
/// <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(); } } } } } }
/// <summary> /// Добавление элементов на полотно двери /// </summary> /// <param name="doorParameters"></param> /// <param name="doorPart"></param> /// <param name="planeXoY"></param> private void DoorModification(DoorParameters doorParameters, ksPart doorPart, ksEntity planeXoY) { ksEntity eyePlaneOffset = doorPart.NewEntity((short) Obj3dType.o3d_planeOffset); ksPlaneOffsetDefinition eyeDefinition = eyePlaneOffset.GetDefinition(); eyeDefinition.SetPlane(planeXoY); eyeDefinition.offset = doorParameters.WeigthDoor; eyePlaneOffset.Create(); ksEntity eyeSketch = doorPart.NewEntity((short) Obj3dType.o3d_sketch); ksSketchDefinition eyeSketchDefinition = eyeSketch.GetDefinition(); eyeSketchDefinition.SetPlane(eyePlaneOffset); eyeSketch.Create(); ksDocument2D eye = eyeSketchDefinition.BeginEdit(); eye.ksCircle(doorParameters.YEye / 2.0, 0, 15, 1); eyeSketchDefinition.EndEdit(); Cut(doorPart, eyeSketch, doorParameters.WeigthDoor); AnimalDoor(doorParameters, doorPart, eyePlaneOffset); DoorKnob(doorParameters, doorPart, eyePlaneOffset); }
/// <summary> /// Построение гладкой части /// </summary> private void CreateConnector(ksPart iPatr) { if (_modelelParameters.Parameter(ParametersName.ConnectionLength).Value != 0) { //Получаем интерфейс базовой плоскости ХОY ksEntity planeZOY = (ksEntity)iPatr.GetDefaultEntity((short)Obj3dType.o3d_planeXOZ); //Создаем новый эскиз ksEntity iSketch = (ksEntity)iPatr.NewEntity((short)Obj3dType.o3d_sketch); //Получаем интерфейс свойств эскиза ksSketchDefinition iDefinitionSketch = (ksSketchDefinition)iSketch.GetDefinition(); //Устанавливаем плоскость эскиза iDefinitionSketch.SetPlane(planeZOY); //Создание эскиза iSketch.Create(); //Создание нового 2Д документа ksDocument2D iDocument2D = (ksDocument2D)iDefinitionSketch.BeginEdit(); //Получение радиуса рукояти var rad = _modelelParameters.Parameter(ParametersName.HandleRadius).Value; //Построение круга iDocument2D.ksCircle(0, 0, rad + 0.1, 1); //Создание эскиза iDefinitionSketch.EndEdit(); //Получение глубины выдавливания var depth = _modelelParameters.Parameter(ParametersName.ConnectionLength).Value / 2; //Выдавливание в обе стороны ExctrusionSketch(iPatr, iSketch, depth, false); ExctrusionSketch(iPatr, iSketch, depth, true); } }
/// <summary> /// Метод, выполняющий вырезание выдавливанием по эскизу /// </summary> /// <param name="part">Интерфейс компонента</param> /// <param name="sketch">Эскиз</param> /// <param name="topHeight">Высота вырезания вверх</param> /// <param name="bottomHeight">Высота вырезания вниз</param> /// <param name="type">Тип выдавливания</param> private void CutExtrusion(ksPart part, ksEntity sketch, double topHeight, double bottomHeight, bool type) { ksEntity entityCutExtrusion = (ksEntity)part.NewEntity((short) Obj3dType.o3d_cutExtrusion); ksCutExtrusionDefinition cutExtrusionDefinition = (ksCutExtrusionDefinition)entityCutExtrusion.GetDefinition(); if (type == false) { cutExtrusionDefinition.directionType = (short)Direction_Type. dtNormal; cutExtrusionDefinition.SetSideParam(true, (short)End_Type. etBlind, topHeight); } if (type == true) { cutExtrusionDefinition.directionType = (short)Direction_Type. dtBoth; cutExtrusionDefinition.SetSideParam(true, (short)End_Type. etBlind, topHeight); cutExtrusionDefinition.SetSideParam(false, (short)End_Type. etBlind, bottomHeight); } cutExtrusionDefinition.SetSketch(sketch); entityCutExtrusion.Create(); }
/// <summary> /// Основание ручки /// </summary> /// <param name="doorParameters"></param> /// <param name="doorPart"></param> /// <param name="eyePlaneOffset"></param> private void HandleBase(DoorParameters doorParameters, ksPart doorPart, ksEntity eyePlaneOffset) { ksEntity keyPlaneOffset = doorPart.NewEntity((short) Obj3dType.o3d_planeOffset); ksPlaneOffsetDefinition pod5 = keyPlaneOffset.GetDefinition(); pod5.SetPlane(eyePlaneOffset); pod5.offset = 25; keyPlaneOffset.Create(); ksEntity keySketch = doorPart.NewEntity((short) Obj3dType.o3d_sketch); ksSketchDefinition keySketchDefinition = keySketch.GetDefinition(); keySketchDefinition.SetPlane(keyPlaneOffset); keySketch.Create(); ksDocument2D key = keySketchDefinition.BeginEdit(); DrawRectangle(key, doorParameters.YKey / 2.0, doorParameters.WidthDoor - 450, 200, 26, -90); keySketchDefinition.EndEdit(); Extrude(doorPart, keySketch, 5, (short)Direction_Type.dtNormal); }
public void Fillet(ksPart iPart, int index, double radius, TeaPotParams teaPotParams) { // Получение интерфейса объекта скругление ksEntity entityFillet = (ksEntity)iPart.NewEntity((int)Obj3dType.o3d_fillet); // Получаем интерфейс параметров объекта скругление ksFilletDefinition filletDefinition = (ksFilletDefinition)entityFillet.GetDefinition(); // Радиус скругления filletDefinition.radius = radius; // Не продолжать по касательным ребрам filletDefinition.tangent = true; // Получаем массив граней объекта ksEntityCollection entityCollectionPart = (ksEntityCollection)iPart.EntityCollection((int)Obj3dType.o3d_face); // Получаем массив скругляемых граней ksEntityCollection entityCollectionFillet = (ksEntityCollection)filletDefinition.array(); entityCollectionFillet.Clear(); //ksEntity ENT = entityCollectionFillet.GetByIndex(0); // Заполняем массив скругляемых объектов entityCollectionFillet.Add(entityCollectionPart.GetByIndex(index)); // Создаем скругление int X = Convert.ToInt32(teaPotParams.TeaPotHandleColor); entityFillet.SetAdvancedColor(X, 2, 2, 2, 2, 1, 2); entityFillet.Create(); }
/// <summary> /// Главнй метод построения детали /// </summary> /// <param name="parameters">Входные параметры детали</param> public void CreateDetail(HandleParameters parameters) { if (_kompas != null) { _doc3D = (ksDocument3D)_kompas.Document3D(); _doc3D.Create(false, true); } var backRadius = parameters.BackDiameter * 5; var backLenght = parameters.BackLenght * 10; var frontLenght = parameters.FrontLenght * 10; var holeRadius = parameters.HoleDiameter * 5; var notchCount = parameters.NotchCount; _doc3D = (ksDocument3D)_kompas.ActiveDocument3D(); _part = (ksPart)_doc3D.GetPart((short)Part_Type.pTop_Part); CreateMainSketch(backRadius, backLenght, frontLenght, holeRadius); RotateSketch(); CreateNotchSketch(); ExtrudeSketch(frontLenght, backLenght, notchCount); }
private ComponentInfo GetParam(ksPart part) { ksMassInertiaParam massInertiaParam = (ksMassInertiaParam)part.CalcMassInertiaProperties((uint)ksLengthUnitsEnum.ksLUnMM); IPropertyMng propertyManager = part as IPropertyMng; //string oboz = propertyManager.GetProperty(kompasDocument, 4); //обозначение //string SSect = propertyManager.GetProperty(kompasDocument, 20); //раздел спецификации ComponentInfo iMSH = new ComponentInfo(); iMSH._MCH.Area = massInertiaParam.F; iMSH._MCH.Mass = massInertiaParam.m; iMSH._MCH.Volume = massInertiaParam.v; iMSH._MCH.Xc = massInertiaParam.xc; iMSH._MCH.Yc = massInertiaParam.yc; iMSH._MCH.Zc = massInertiaParam.zc; iMSH.FFN = part.fileName; iMSH.material = part.material; iMSH.Oboz = part.marking; iMSH.Naim = part.name; iMSH.Mass = part.GetMass(); iMSH.isDetal = part.IsDetail(); iMSH.standardComponent = part.standardComponent; iMSH.QNT = 1; iMSH.Key = part.fileName + "|" + part.marking; return(iMSH); }
public void Build(ksPart iPart, KompasObject _kompas, TeaPotParams teaPotParams) { this.iPart = iPart; CreateBody(iPart, _kompas, teaPotParams); CreateSpout(iPart, _kompas, teaPotParams); CreateHandle(iPart, _kompas, teaPotParams); }
/// <summary> /// Создание отверстий. /// </summary> /// <param name="part">Ссылка на деталь.</param> /// <param name="distanceBetweenHoles">Расстояние между точками.</param> /// <param name="width">Толщина проставки.</param> /// <param name="countHoles">Количество отверстий</param> public void MakeHoles(ksPart part, float distanceBetweenHoles, float width, int countHoles) { var smallHoles = MakeBaseCircle(part, 12.2f, distanceBetweenHoles / 2); var extrudedSmallHole = ExtrusionEntity(part, width, smallHoles); var smallCircularHoles = CircularEntity(part, countHoles * 2, extrudedSmallHole); var bigCirclesFromOtherSide = MakeBaseCircle(part, 20, -distanceBetweenHoles / 2, 5f); if (countHoles % 2 == 0) { var sin = (float)(-distanceBetweenHoles / 2 * Math.Sin(Math.PI / countHoles)); var cos = (float)(-distanceBetweenHoles / 2 * Math.Cos(Math.PI / countHoles)); bigCirclesFromOtherSide = MakeBaseCircle(part, 20, cos, 5f, sin); } var extrudedBigHoleFromOtherSide = ExtrusionEntity (part, width - 5f, bigCirclesFromOtherSide, false); var bigCircularHolesFromOtherSide = CircularEntity (part, countHoles, extrudedBigHoleFromOtherSide); var bigCircles = MakeBaseCircle(part, 20, distanceBetweenHoles / 2); var extrudedBigHole = ExtrusionEntity(part, width - 5f, bigCircles); var bigCircularHoles = CircularEntity(part, countHoles, extrudedBigHole); }
/// <summary> /// Создать коническую спираль. /// </summary> /// <param name="sketch">Эскиз рефленности стакана.</param> /// <param name="part">Сборка детали.</param> /// <returns>Коническая спираль для создания полоски стакана.</returns> private ksEntity CreateConicSpiral(ksEntity sketch, ksPart part) { var extrConicSpiral = (ksEntity)part.NewEntity( (short)Obj3dType.o3d_conicSpiral); extrConicSpiral.name = "Коническая спираль для полоски"; var extrDef = (ksConicSpiralDefinition)extrConicSpiral.GetDefinition(); //построение по шагу витков и высоте extrDef.buildMode = 1; extrDef.buildDir = false; //способ задания конечного диаметра: // по углу наклона образующей extrDef.terminalDiamType = 2; extrDef.step = 459.509; extrDef.heightType = 0; extrDef.height = _glass.HeightFaceted; extrDef.initialDiam = _calcParams.DiameterFacetedStart; //наклон образующей внутрь extrDef.tiltAngleHow = true; extrDef.tiltAngle = 5; extrDef.firstAngle = 25.0; extrDef.SetPlane(sketch); extrConicSpiral.Create(); return(extrConicSpiral); }
/// <summary> /// Создать с помощью кинематической операции /// полоску гофрированного стакана. /// </summary> /// <param name="sketch">Эскиз рефленности стакана.</param> /// <param name="part">Сборка детали.</param> /// <param name="extrConicSpiral">Коническая спираль /// для создания полоски стакана.</param> /// <returns>Модель полоски(узора) /// для гофрированного стакана.</returns> private ksEntity CreateKinematicOperation( ksEntity sketch, ksPart part, ksEntity extrConicSpiral) { var extrKin = (ksEntity)part.NewEntity( (short)Obj3dType.o3d_baseEvolution); extrKin.name = "Кинематическая операция для полоски"; var extrDefKin = (ksBaseEvolutionDefinition)extrKin.GetDefinition(); //образующая при переносе сохраняет // исходный угол с направляющей extrDefKin.sketchShiftType = 1; //установка эскиза сечения extrDefKin.SetSketch(sketch); var strips = (ksEntityCollection)extrDefKin.PathPartArray(); strips.Clear(); //добавить в массив эскиз // с траекторией(конической спиралью) strips.Add(extrConicSpiral); extrKin.Create(); return(extrKin); }
/// <summary> /// Копировать полоски(узор) по концетрической сетке. /// </summary> /// <param name="part">Сборка детали.</param> /// <param name="extrKin">Эскиз полосок /// гофрированного стакана.</param> private void CopyByCircularGrid(ksPart part, ksEntity extrKin) { var extrCirc = (ksEntity)part.NewEntity( (short)Obj3dType.o3d_circularCopy); extrCirc.name = "Копирование элементов" + "по концентрической сетке"; var axisOZ = (ksEntity)part.GetDefaultEntity( (short)Obj3dType.o3d_axisOZ); var extrDefCirc = (ksCircularCopyDefinition)extrCirc.GetDefinition(); extrDefCirc.SetAxis(axisOZ); //количество полосок extrDefCirc.count2 = _glass.CountFaceted; extrDefCirc.inverce = false; extrDefCirc.geomArray = false; //полностью вокруг стенки стакана extrDefCirc.step2 = 360; var copyStrips = (ksEntityCollection)extrDefCirc.GetOperationArray(); copyStrips.Clear(); copyStrips.Add(extrKin); extrCirc.Create(); }
public void CreateSpout(ksPart iPart, KompasObject _kompas, TeaPotParams teaPotParams) { double spout = (teaPotParams.TeaPotDiameter / 5); double offset = teaPotParams.TeaPotHeight - spout * 1.5; double width = spout; // spoutWidth double height = spout; // spoutHeigth ksEntity iSketch; ksSketchDefinition iDefinitionSketch; CreateSketch(out iSketch, out iDefinitionSketch, offset); // Интерфейс для рисования = на скетче; ksDocument2D iDocument2D = (ksDocument2D)iDefinitionSketch.BeginEdit(); // Построить прямоугольник (x1,y1, x2,y2, style) ksRectangleParam par1 = (ksRectangleParam)_kompas.GetParamStruct((short)StructType2DEnum.ko_RectangleParam); par1.x = (teaPotParams.TeaPotDiameter / 2) - 5; par1.height = width; // spoutWidth. par1.y = -(par1.height / 2); par1.width = teaPotParams.TeaPotSpoutLength; //spoutLength par1.style = 1; // При нуле не видно деталь. iDocument2D.ksRectangle(par1); // Закончить редактировать эскиз iDefinitionSketch.EndEdit(); int X = Convert.ToInt32(teaPotParams.TeaPotHandleColor); ExctrusionSketch(iPart, iSketch, height, true, X); Fillet(iPart, 7, width / 2, teaPotParams); }
/// <summary> /// Конструктор /// </summary> /// <param name="document3D"></param> /// <param name="kompas"></param> /// <param name="infAir"></param> public CreatingModel(ksDocument3D document3D, KompasObject kompas, InfAirliner infAir) { _doc3D = document3D; _kompasObj = kompas; _infAirliner = infAir; _part = (ksPart)_doc3D.GetPart((short)Part_Type.pTop_Part); }
private void CreateVerticalTorsLeft(ksPart part, double totalLenght, double gridLenght, double capsuleRadius) { var start = totalLenght; while (start > totalLenght - capsuleRadius) { start -= 2 * gridLenght; var currentPlane = (ksEntity)part.GetDefaultEntity((short)Obj3dType.o3d_planeXOZ); var _entitySketch = (ksEntity)part.NewEntity((short)Obj3dType.o3d_sketch); var _sketchDefinition = (ksSketchDefinition)_entitySketch.GetDefinition(); _sketchDefinition.SetPlane(currentPlane); _entitySketch.name = "Vertical : " + start.ToString(); _entitySketch.Create(); var _sketchEdit = (ksDocument2D)_sketchDefinition.BeginEdit(); _sketchEdit.ksCircle(start, -Math.Sqrt(Math.Pow(capsuleRadius, 2) - Math.Pow(start - totalLenght + capsuleRadius, 2)), gridLenght / 2, 1); _sketchEdit.ksLineSeg(totalLenght - capsuleRadius, -capsuleRadius, totalLenght - capsuleRadius, capsuleRadius, 3); _sketchDefinition.EndEdit(); var entityRotated = (ksEntity)part.NewEntity((short)Obj3dType.o3d_baseRotated); var entityRotatedDefinition = (ksBaseRotatedDefinition)entityRotated.GetDefinition(); entityRotatedDefinition.directionType = 3; entityRotatedDefinition.SetSideParam(true, 180); entityRotatedDefinition.SetSketch(_entitySketch); entityRotated.Create(); } }
/// <summary> /// Метод, выполняющий выдавливание по эскизу /// </summary> /// <param name="part">Интерфейс компонента</param> /// <param name="sketch">Эскиз</param> /// <param name="height">Высота выдавливания</param> /// <param name="type">Тип выдавливания</param> private void ExtrudeSketch(ksPart part, ksEntity sketch, double height, bool type) { ksEntity entityExtrusion = (ksEntity)part.NewEntity((short) Obj3dType.o3d_baseExtrusion); ksBaseExtrusionDefinition extrusionDefinition = (ksBaseExtrusionDefinition)entityExtrusion.GetDefinition(); if (type == false) { extrusionDefinition.directionType = (short)Direction_Type. dtReverse; extrusionDefinition.SetSideParam(false, (short)End_Type.etBlind, height); } if (type == true) { extrusionDefinition.directionType = (short)Direction_Type. dtNormal; extrusionDefinition.SetSideParam(true, (short)End_Type.etBlind, height); } extrusionDefinition.SetSketch(sketch); entityExtrusion.Create(); }
private void CreateHorizontalTors(ksPart part, double totalLenght, double gridLenght, double capsuleRadius) { var start = totalLenght - capsuleRadius; while (start < totalLenght) { var currentPlane = (ksEntity)part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY); var _entitySketch = (ksEntity)part.NewEntity((short)Obj3dType.o3d_sketch); var _sketchDefinition = (ksSketchDefinition)_entitySketch.GetDefinition(); _sketchDefinition.SetPlane(currentPlane); _entitySketch.name = "Horizontal : " /*+ start.ToString()*/; _entitySketch.Create(); var _sketchEdit = (ksDocument2D)_sketchDefinition.BeginEdit(); var entityRotated = (ksEntity)part.NewEntity((short)Obj3dType.o3d_baseRotated); var entityRotatedDefinition = (ksBaseRotatedDefinition)entityRotated.GetDefinition(); start += 2 * gridLenght; _sketchEdit.ksCircle(start, Math.Sqrt(Math.Pow(capsuleRadius, 2) - Math.Pow(start - totalLenght + capsuleRadius, 2)), gridLenght / 2, 1); _sketchEdit.ksLineSeg(0, 0, totalLenght, 0, 3); _sketchDefinition.EndEdit(); entityRotatedDefinition.directionType = 0; entityRotatedDefinition.SetSideParam(true, 360); entityRotatedDefinition.SetSketch(_entitySketch); entityRotated.Create(); } }
/// <summary> /// Создание головки /// </summary> /// <param name="diameterHead">Диаметр головки </param> /// <param name="lengthHead">Длина головки </param> private void BuildHead(double diameterHead, double lengthHead) { #region Константы для головки const int part = -1; const int sketch = 5; const int planeXOY = 1; const int baseExtrusion = 24; const int shaded = 3; const int etBlind = 0; #endregion //Эскиз головки _part = _doc3D.GetPart(part); _entity = _part.NewEntity(sketch); ksSketchDefinition SketchDefinition = _entity.GetDefinition(); ksEntity EntityPlane = _part.GetDefaultEntity(planeXOY); SketchDefinition.SetPlane(EntityPlane); _entity.Create(); ksDocument2D Document2D = SketchDefinition.BeginEdit(); Document2D.ksCircle(0, 0, diameterHead / 2, 1); SketchDefinition.EndEdit(); //Выдавливание головки ksEntity EntityExtrusion = _part.NewEntity(baseExtrusion); ksBaseExtrusionDefinition BaseExtrusionDefinition = EntityExtrusion.GetDefinition(); BaseExtrusionDefinition.SetSideParam(true, etBlind, lengthHead, 0, true); BaseExtrusionDefinition.SetSketch(_entity); EntityExtrusion.Create(); _doc3D.drawMode = shaded; _doc3D.shadedWireframe = true; }
/// <summary> /// Окрашивание места для хвата в чёрный /// </summary> /// <param name="iPart">Интерфейс детали</param> /// <param name="side">Направление</param> private void CreateBlackColor(ksPart iPart, bool side) { //Получение радиуса ручки var X = _modelelParameters.Parameter(ParametersName.HandleRadius).Value; //Получение длины гладкой части var Y = _modelelParameters.Parameter(ParametersName.ConnectionLength).Value + 5; var Z = 0; //Получаем массив граней объекта ksEntityCollection entityCollectionPart = (ksEntityCollection)iPart.EntityCollection((short)Obj3dType.o3d_face); //Сортируем грани по заданным координатам if (side == true) { entityCollectionPart.SelectByPoint(X, Y, Z); } else { entityCollectionPart.SelectByPoint(X, -Y, Z); } //Получаем первый элмент массива ksEntity element = entityCollectionPart.First(); //Получаем интерфейс управления цветом детали ksColorParam colorParam = element.ColorParam(); //Назначаем цвет colorParam.color = 333333; //Применяем изменения element.Update(); }
/// <summary> /// Создание двери /// </summary> /// <param name="doorParameters"></param> public void BuildDoor(DoorParameters doorParameters) { ConnectToKompas(); ksDocument3D doc = Kompas3D.Document3D(); doc.Create(); ksPart doorPart = doc.GetPart((short) Part_Type.pTop_Part); ksEntity planeXoY = doorPart.GetDefaultEntity((short) Obj3dType.o3d_planeXOY); ksEntity sketch = doorPart.NewEntity((short) Obj3dType.o3d_sketch); ksSketchDefinition sd = sketch.GetDefinition(); sd.SetPlane(planeXoY); sketch.Create(); ksDocument2D topSketch = sd.BeginEdit(); DrawRectangle(topSketch, -doorParameters.HeightDoor / 2.0, -doorParameters.WidthDoor / 2.0, doorParameters.HeightDoor, doorParameters.WidthDoor, null); sd.EndEdit(); Extrude(doorPart, sketch, doorParameters.WeigthDoor, (short)Direction_Type.dtNormal); DoorModification(doorParameters, doorPart, planeXoY); }
/// <summary> /// Построение ручки /// </summary> /// <param name="window"></param> /// <param name="coordinatesGrid">координатная сетка</param> /// <param name="windowPart">указатель на деталь</param> /// <param name="planeXoy">координатная плоскость</param> private void DrawHandle(WindowParametrs window, Dictionary <int, Dictionary <string, double> > coordinatesGrid, ksPart windowPart, ksEntity planeXoy) { var xStartPartOne = coordinatesGrid[6]["xStartPartOne"]; var yStartPartOne = coordinatesGrid[6]["yStartPartOne"]; var heigthPartOne = coordinatesGrid[6]["HeigthPartOne"]; var widthPartOne = coordinatesGrid[6]["WidthPartOne"]; var weithPartOne = coordinatesGrid[6]["WeigthPartOne"]; var planeOffsetOne = CreateOffsetPlane(windowPart, planeXoy, window.LengthWeight * 2); ExtrudeOdject(heigthPartOne, widthPartOne, weithPartOne, windowPart, planeOffsetOne, xStartPartOne, yStartPartOne, Obj3dType.o3d_bossExtrusion); var xStartPartTwo = coordinatesGrid[6]["xStartPartTwo"]; var yStartPartTwo = coordinatesGrid[6]["yStartPartTwo"]; var heigthPartTwo = coordinatesGrid[6]["HeigthPartTwo"]; var widthPartTwo = coordinatesGrid[6]["WidthPartTwo"]; var weithPartTwo = coordinatesGrid[6]["WeigthPartTwo"]; var planeOffsetTwo = CreateOffsetPlane(windowPart, planeXoy, window.LengthWeight * 2 + weithPartOne); ExtrudeOdject(heigthPartTwo, widthPartTwo, weithPartTwo, windowPart, planeOffsetTwo, xStartPartTwo, yStartPartTwo, Obj3dType.o3d_bossExtrusion); }
/// <summary> /// Создание Эскиза /// </summary> /// <param name="part">Деталь</param> /// <param name="ksEntityDrawStande">Эскиз детали</param> /// <param name="ksEntityPlaneOffset">Сдвиг эскиза</param> private void CreatSketchThree(ksPart part, ksEntity ksEntityDrawStande, ksEntity ksEntityPlaneOffset) { ksSketchDefinition ksSketchDefinition; ksDocument2D _ksDocument2D; ksEntity ksEntityPlane; ksSketchDefinition = (ksSketchDefinition)ksEntityDrawStande.GetDefinition(); ksEntityPlane = (ksEntity)part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY); ksSketchDefinition.SetPlane(ksEntityPlaneOffset); ksEntityDrawStande.Create(); ksRectangleParam ksRectangleParam; ksRectangleParam = (ksRectangleParam)_kompasObject.GetParamStruct( (int)StructType2DEnum.ko_RectangleParam); ksRectangleParam.ang = 0; ksRectangleParam.height = _monitorSetting.StandHeight; ksRectangleParam.width = _monitorSetting.StandeWight; ksRectangleParam.style = 1; ksRectangleParam.x = (_monitorSetting.MonitorWight + _additionalWight) / 2 - (_monitorSetting.StandeWight / 2); ksRectangleParam.y = _monitorSetting.MonitorHeight / 2; _ksDocument2D = (ksDocument2D)ksSketchDefinition.BeginEdit(); _ksDocument2D.ksRectangle(ksRectangleParam, 0); ksSketchDefinition.EndEdit(); }
/// <summary> /// Создать паз /// </summary> /// <param name="shim">Параметры шайбы</param> /// <param name="part">Компонент сборки</param> private void CreateGroove(ShimSettings shim, ksPart part) { // Создаем эскиз для паза ksEntity sketchGroove; ksSketchDefinition sketchGrooveDefinition; CreateSketch(part, out sketchGroove, out sketchGrooveDefinition, (short)Obj3dType.o3d_planeXOZ); // Рисуем паз на эскизе ksDocument2D GrooveEdit = sketchGrooveDefinition.BeginEdit(); GrooveEdit.ksCircle(shim.InnerRadius, 0, shim.GrooveRadius, 1); sketchGrooveDefinition.EndEdit(); // Вырезаем паз ksEntity cutGrooveExtrude = part.NewEntity((short)Obj3dType.o3d_cutExtrusion); ksCutExtrusionDefinition cutGrooveExtrudeDefinition = cutGrooveExtrude.GetDefinition(); cutGrooveExtrudeDefinition.directionType = (short)Direction_Type.dtBoth; cutGrooveExtrudeDefinition.SetSketch(sketchGroove); ksExtrusionParam cutGrooveExtrudeParam = cutGrooveExtrudeDefinition.ExtrusionParam(); cutGrooveExtrudeParam.depthNormal = shim.Height; cutGrooveExtrudeParam.depthReverse = shim.Height; cutGrooveExtrude.Create(); }
/// <summary> /// Построение стакана. /// </summary> /// <param name="parameters">Параметры стакана.</param> /// <param name="checkFaceted">Определяем, граненый ли стакан.</param> public void CreateDetail(GlassfulParametrs parameters, bool checkFaceted) { if (_kompas != null) { _doc3D = (ksDocument3D)_kompas.Document3D(); _doc3D.Create(false, true); } var wallwidth = parameters.WallWidth; var highdiameter = parameters.HighDiameter; var height = parameters.Height; var bottomthickness = parameters.BottomThickness; var lowdiameter = parameters.LowDiameter; _doc3D = (ksDocument3D)_kompas.ActiveDocument3D(); _part = (ksPart)_doc3D.GetPart((short)Part_Type.pTop_Part); if (checkFaceted) // Определяем реализацию, если мы нажали на чекбокс, то идем по вектке граненого стакана { BuildFaceted(wallwidth, highdiameter, height, bottomthickness, lowdiameter); } else // Иначе строим обычный стакан { GlassfulSketch(wallwidth, highdiameter, height, bottomthickness, lowdiameter); } }
/// <summary> /// Muffler parameters /// </summary> /// <param name="document3DPart">Part with detail in 3D document</param> /// <param name="basePlaneAxis">Axis of base plane of muffler</param> /// <param name="direction">Direction type of muffler</param> /// <param name="basePlanePoint">Point of base plane of muffler</param> public MufflerParameters(ksPart document3DPart, Obj3dType basePlaneAxis, Direction_Type direction, KompasPoint2D basePlanePoint) { Document3DPart = document3DPart; BasePlaneAxis = basePlaneAxis; Direction = direction; BasePlanePoint = basePlanePoint; }
/// <summary> /// Сгладить дно и горлышко болванки стакана. /// </summary> /// <param name="glass">Параметры стакана.</param> /// <param name="part">Сборка детали.</param> private void FilletedBottomAndTop(IGlass glass, ksPart part) { //дно стакана var rBottom = glass.DiameterBottom / 2; var pointBottom = new Point3D(_startX, rBottom, 0); var edge0 = _kompas.FindIntersectionPointWithEdge( part, pointBottom); _kompas.FilletedOnEdge(part, edge0, _calcParams.RadiusBottomFilleted); //с внешней стороны диаметр горлышка var pointTop = new Point3D(_startX, _calcParams.DiameterTop / 2, glass.Height); var edge = _kompas.FindIntersectionPointWithEdge( part, pointTop); _kompas.FilletedOnEdge(part, edge, _calcParams.RadiusTopFilleted); //с внутренней стороны диаметр горлышка // (вырезаемых внутренностей) var pointTop2 = new Point3D(_startX, _calcParams.DiameterSideCutting / 2, glass.Height); var edge2 = _kompas.FindIntersectionPointWithEdge( part, pointTop2); _kompas.FilletedOnEdge(part, edge2, _calcParams.RadiusTopFilleted); }
public void getParts() { ksDocument3D doc = _kompas.ActiveDocument3D(); var parts = doc.PartCollection(true); List <ksPart> partsList = new List <ksPart>(); try { var i = -1; while (true) { ksPart part = doc.GetPart(i); if (part == null) { break; } partsList.Add(part); i++; } } catch (Exception) { // throw; } var ss = parts[1].VariableCollection(); //_kompas.ksMessage() }
/// <summary> /// Создает новый документ. /// </summary> public void NewDocument() { _doc3D = (ksDocument3D)_kompas.Document3D(); _doc3D.Create(); Part = (ksPart)_doc3D.GetPart((short)Part_Type.pTop_Part); }