Files
kompas3d-mcp/tests/Kompas.Mcp.Tests/Integration/ModelingTests.cs
T
mikhail af6adc390e feat(core): PartModeler — эскизы и выдавливание (цикл моделирования)
- BasePlane (XOY/XOZ/YOZ) + маппинг в Obj3dType
- PartModeler (API5 ksPart): OpenSketch/AddLine/AddCircle/AddRectangle/CloseSketch,
  Extrude (boss/cut, blind/throughAll), Rebuild; реестр эскизов и операций по id
- tests: построение цилиндра со сквозным отверстием + снимок (визуально проверено)

Полный цикл "эскиз -> выдавливание -> эскиз -> сквозной вырез -> снимок" работает.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 23:52:55 +03:00

56 lines
2.1 KiB
C#

using Kompas.Mcp.Core.Documents;
using Kompas.Mcp.Core.Modeling;
using Kompas.Mcp.Core.Vision;
namespace Kompas.Mcp.Tests.Integration;
/// <summary>Интеграция: построение 3D (эскиз → выдавливание) и снимок.</summary>
[Trait("Category", "Integration")]
[Collection(KompasCollection.Name)]
public sealed class ModelingTests
{
private readonly DocumentService _docs;
private readonly PartModeler _modeler;
private readonly SnapshotService _snap;
public ModelingTests(KompasFixture fx)
{
_docs = new DocumentService(fx.Session, fx.Dispatcher);
_modeler = new PartModeler(fx.Session, fx.Dispatcher);
_snap = new SnapshotService(fx.Session, fx.Dispatcher);
}
[Fact]
public async Task Build_cylinder_then_cut_hole_and_snapshot()
{
await _docs.CreateAsync(KompasDocumentType.Part);
try
{
// Эскиз 1: окружность R20 на XOY → выдавить boss на 40 (цилиндр).
var s1 = await _modeler.OpenSketchAsync(BasePlane.XOY);
await _modeler.AddCircleAsync(s1, 0, 0, 20);
await _modeler.CloseSketchAsync(s1);
var boss = await _modeler.ExtrudeAsync(s1, depth: 40);
Assert.True(boss > 0);
// Эскиз 2: окружность R8 на XOY → вырезать насквозь (отверстие).
var s2 = await _modeler.OpenSketchAsync(BasePlane.XOY);
await _modeler.AddCircleAsync(s2, 0, 0, 8);
await _modeler.CloseSketchAsync(s2);
var cut = await _modeler.ExtrudeAsync(s2, depth: 40, cut: true, throughAll: true);
Assert.True(cut > 0);
await _modeler.RebuildAsync();
var path = TestPaths.NewFile(".png");
var snap = await _snap.CaptureActiveModelAsync(saveToFile: path);
Assert.True(snap.Bytes.Length > 1000, "Снимок цилиндра подозрительно мал.");
Assert.True(File.Exists(path));
}
finally
{
await _docs.CloseAsync(save: false);
}
}
}