/
spruttechnology
/
cam-api-examples
Обзор
Документация
Войти
/
spruttechnology
/
cam-api-examples
Код
Запросы
3
Задачи
Пакеты
0
Релизы
1
Аналитика
v19/develop
FullWorkflow/FullWorkflow3DProject/project/main/ModelHelper.cs
55 строк
2 KB
renal
Исправления для компиляции
22 июн 2026, 15:57
22 июн 2026, 15:57
c9cf95b
Код
Авторство
О чём код?
using CAMAPI.Application; using CAMAPI.ApplicationMainForm; using CAMAPI.DotnetHelper; using CAMAPI.Project; using CAMAPI.Singletons; namespace FullWorkflow3DProject; /// <summary> /// Operations over the model /// </summary> public static class ModelHelper { /// <summary> /// Relative path to the importing file /// </summary> private const string ImportFilePath = @"Milling_25D\Part1.igs"; /// <summary> /// Prepare the model: import file /// </summary> public static void PrepareModel(ComWrapper<ICamApiApplication> applicationCom, ComWrapper<ICamApiProject> activeProjectCom, ComWrapper<ICamApiPaths> pathsHelperCom) { // switch to model tab applicationCom.Invoke(application => { application.MainWorkMode = TMainWorkMode.mwmModel; }); // import file ImportFile(activeProjectCom, pathsHelperCom); } /// <summary> /// Import a file to the project /// </summary> private static void ImportFile(ComWrapper<ICamApiProject> projectCom, ComWrapper<ICamApiPaths> pathsHelperCom) { // get the path to the file we will import var modelsFolder = pathsHelperCom.Invoke(pathsHelper => pathsHelper.ModelsFolder) ?? throw new Exception("Cannot get models folder"); var importFile = Path.Combine(modelsFolder, ImportFilePath); if (!File.Exists(importFile)) throw new Exception($"Cannot find file to import: {importFile}"); // import the file using var geomImporterCom = projectCom.InvokeAndWrap(project => project.GeomImporter); geomImporterCom.Invoke(importer => { importer.ImportFile(importFile, "Part", false); }); } }