vite, решил вернуться обратно к T-flex CAD Open API. Починил проблемы с библиотеками.
Прикладываю свой код, но не работает ни импорт, ни экспорт.
Мучаюсь уже долго, никак не получается ~~:-
[CODE]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TFlex.Model;
using System.IO;
namespace tflex_converter_chsarp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now + " Starting...");
TFlex.Application.InitSession(GetSetup());
stp2grb(@"C:\sss.stp", @"C:\sss.grb");
grb2stp(@"C:\asd.grb", @"C:\asd.stp");
Console.WriteLine(DateTime.Now + " Finish");
}
static TFlex.ApplicationSessionSetup GetSetup()
{
TFlex.ApplicationSessionSetup setup = new TFlex.ApplicationSessionSetup();
setup.ReadOnly = false;
setup.EnableMacros = true;
setup.PromptToSaveModifiedDocuments = false;
setup.Enable3D = true;
//TFlex.Application.Options.Precise3DObjectSelector = false;
return setup;
}
static void stp2grb(string src, string dst)
{
if (!File.Exists(src))
{
Console.WriteLine("File {0} does not exist", src);
return;
}
Document document = TFlex.Application.NewDocument();
ImportFromSTEP import = new ImportFromSTEP(document);
import.ImportFormat = ImportSTEPFormat.Assembly;
bool isImported = import.Import(src);
Console.WriteLine("IsImported: " + isImported.ToString());
bool isSaved = document.SaveAs(dst);
Console.WriteLine("isSaved: " + isSaved.ToString());
}
static void grb2stp(string src, string dst)
{
if (!File.Exists(src))
{
Console.WriteLine("File {0} does not exist", src);
return;
}
Document document = TFlex.Application.OpenAsDocument(src);
ExportToStep toStep = new ExportToStep(document); // = new ExportToStep();
bool IsExported = toStep.Export(dst);
Console.WriteLine("IsExported: " + IsExported.ToString());
}
}
}
[/CODE]