/// <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="windowsParametrs"></param> public CoordinatesGrid(WindowParametrs windowsParametrs) { _windowsParametrs = windowsParametrs; _offset = 20; InitSectionsCoordinations(); _grid.Add(5, InitOpenSection()); if (_windowsParametrs.OpenSection != 0) { _grid.Add(6, InitHandle()); } }
/// <summary> /// Построение всех секций /// </summary> /// <param name="window"></param> /// <param name="windowPart">указатель на деталь</param> /// <param name="planeXoy">координатная плоскость</param> /// <param name="height">высота</param> /// <param name="width">ширина</param> /// <param name="weigth">глубина</param> /// <param name="coordinatesGrid">координатная сетка</param> /// <param name="widthNotch">ширина выреза</param> /// <param name="heighNotch">высота выреза</param> /// <param name="weigthNotch">глубина выреза</param> private void DrawAllSections(WindowParametrs window, ksPart windowPart, ksEntity planeXoy, int height, int width, int weigth, Dictionary <int, Dictionary <string, double> > coordinatesGrid, int widthNotch, int heighNotch, int weigthNotch) { for (var i = 1; i <= window.SectionNumber; i++) { DrawSection(windowPart, planeXoy, height, width / 2.0, weigth, coordinatesGrid[i]["xStartExtrude"], coordinatesGrid[i]["yStartExtrude"], coordinatesGrid[i]["xStartNotch"], coordinatesGrid[i]["yStartNotch"], widthNotch, heighNotch, weigthNotch); } }
/// <summary> /// метод для построения окна в компасе /// </summary> /// <param name="window"></param> public void BuildWindow(WindowParametrs window) { StartAndConnectToKompas(); if (_kompas == null) { throw new Exception("Не возможно построить" + " деталь. Нет связи с Kompas."); } if (window == null) { throw new ArgumentNullException(nameof(window)); } var coordinatesGrid = new CoordinatesGrid(window).Grid; var height = window.LengthHeight; var width = window.LengthWidth; var weigth = window.LengthWeight; var offset = 20; var widthNotch = width / 2 - offset * 2; var heighNotch = height - offset * 2; var weigthNotch = weigth + 100; ksDocument3D document = _kompas.Document3D(); document.Create(); ksPart windowPart = document.GetPart((short) Part_Type.pTop_Part); ksEntity planeXoy = windowPart.GetDefaultEntity((short) Obj3dType.o3d_planeXOY); DrawAllSections(window, windowPart, planeXoy, height, width, weigth, coordinatesGrid, widthNotch, heighNotch, weigthNotch); if (window.OpenSection != 0) { DrawOpenSection(windowPart, planeXoy, coordinatesGrid, weigth, window); } }
/// <summary> /// Построение открытой секции /// </summary> /// <param name="windowPart">указатель на деталь</param> /// <param name="planeXoy">координатная плоскость</param> /// <param name="coordinatesGrid">сетка координат</param> /// <param name="weigth">ширина</param> /// <param name="window"></param> private void DrawOpenSection(ksPart windowPart, ksEntity planeXoy, Dictionary <int, Dictionary <string, double> > coordinatesGrid, int weigth, WindowParametrs window) { var planeOffset = CreateOffsetPlane(windowPart, planeXoy, weigth); DrawSection(windowPart, planeOffset, coordinatesGrid[5]["heighSectionExtrude"], coordinatesGrid[5]["widthSectionExtrude"], weigth, coordinatesGrid[5]["xStartExtrude"], coordinatesGrid[5]["yStartExtrude"], coordinatesGrid[5]["xStartNotch"], coordinatesGrid[5]["yStartNotch"], coordinatesGrid[5]["widthSectionNotch"], coordinatesGrid[5]["heightSectionNotch"], coordinatesGrid[5]["weigthSectionNotch"]); DrawHandle(window, coordinatesGrid, windowPart, planeXoy); }
/// <summary> /// Нажатие кнопки построения /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Build_window_Click(object sender, EventArgs e) { var window = new WindowParametrs { SectionNumber = Convert.ToInt32(Section.SelectedItem), OpenSection = Convert.ToInt32(OpenSection.SelectedItem), LengthWidth = Convert.ToInt32(Width.Value), LengthHeight = Convert.ToInt32(Height.Value), LengthWeight = Convert.ToInt32(Weight.Value) }; if (Left.Checked) { window.HandlePosition = HandlePosition.Left; } if (Right.Checked) { window.HandlePosition = HandlePosition.Right; } _kompas.BuildWindow(window); }