Init
This commit is contained in:
196
exchange/exchangesource/NetWrapper/ConsoleApplication/Program.cs
Normal file
196
exchange/exchangesource/NetWrapper/ConsoleApplication/Program.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.
|
||||
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
||||
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
||||
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
||||
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
|
||||
* scope and manner of such use.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
||||
using TechSoft3D.HOOPS;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static Exchange m_pExchange;
|
||||
|
||||
static string m_pcFileName;
|
||||
static int m_iProgressBareSize;
|
||||
static int m_iStart;
|
||||
|
||||
//##############################################################################################################
|
||||
static void stFCTStart(int i)
|
||||
{
|
||||
m_iStart = i;
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Console.WriteLine("Start Parsing File: {0}", m_pcFileName);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
|
||||
Console.WriteLine("Start Writing to Parasolid");
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
// m_pExchange.Break();
|
||||
Console.WriteLine("Start Reading File {0}", m_pcFileName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//##############################################################################################################
|
||||
static void stFCTitle(string str)
|
||||
{
|
||||
m_pcFileName = str;
|
||||
}
|
||||
|
||||
//##############################################################################################################
|
||||
static void stFCTSize(int i)
|
||||
{
|
||||
m_iProgressBareSize = i;
|
||||
}
|
||||
|
||||
//##############################################################################################################
|
||||
static void stFCTIncr(int i)
|
||||
{
|
||||
if (m_iProgressBareSize != 0)
|
||||
{
|
||||
int iPercentage = (int)(i * 100 / (double)m_iProgressBareSize);
|
||||
Console.WriteLine("Progress: {0} % ", iPercentage);
|
||||
}
|
||||
}
|
||||
|
||||
//##############################################################################################################
|
||||
static void stFCTEnd()
|
||||
{
|
||||
Console.WriteLine("Progress: 100/% ");
|
||||
m_iProgressBareSize = 0;
|
||||
|
||||
}
|
||||
|
||||
static int stFCTReportMessage(string Msg)
|
||||
{
|
||||
Console.Write(Msg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int stFCTkReportWarning(string Code,string Msg)
|
||||
{
|
||||
Console.Write("WARNING " + Code + " " + Msg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int stFCTReportError(string Code,string Msg)
|
||||
{
|
||||
Console.Write("ERROR " + Code + " " + Msg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//##############################################################################################################
|
||||
static bool stTranslate(string InputCADFile, string OutputXTFile, string LogFile, bool bWriteBlankedEntities)
|
||||
{
|
||||
if (m_pExchange == null)
|
||||
{
|
||||
m_pExchange = new Exchange();
|
||||
|
||||
if (!m_pExchange.Init())
|
||||
{
|
||||
Console.WriteLine("Cannot initialize HOOPS Exchange");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LogFile.Length > 0)
|
||||
m_pExchange.SetLogFile(LogFile);
|
||||
|
||||
Exchange.CallbackStart pStart = new Exchange.CallbackStart(stFCTStart);
|
||||
Exchange.CallbackTitle pTitle = new Exchange.CallbackTitle(stFCTitle);
|
||||
Exchange.CallbackIncrement pIncr = new Exchange.CallbackIncrement(stFCTIncr);
|
||||
Exchange.CallbackSize pSize = new Exchange.CallbackSize(stFCTSize);
|
||||
Exchange.CallbackEnd pEnd = new Exchange.CallbackEnd(stFCTEnd);
|
||||
|
||||
Exchange.CallbackReportMessage pMessage = new Exchange.CallbackReportMessage(stFCTReportMessage);
|
||||
Exchange.CallbackReportWarning pWarning = new Exchange.CallbackReportWarning(stFCTkReportWarning);
|
||||
Exchange.CallbackReportError pError = new Exchange.CallbackReportError(stFCTReportError);
|
||||
|
||||
m_pExchange.SetCallBackFct(pStart, pTitle, pSize, pIncr, pEnd);
|
||||
m_pExchange.SetCallBackMessageFct(pMessage, pWarning, pError);
|
||||
}
|
||||
|
||||
IDictionary<string, string> sOptions = new Dictionary<string, string>();
|
||||
sOptions.Add("WriteBlankedEntities", bWriteBlankedEntities ? "true" : "false");
|
||||
|
||||
sOptions.Add("General.ReadSolids", "true");
|
||||
sOptions.Add("General.ReadSurfaces", "false");
|
||||
sOptions.Add("General.ReadWireframes", "false");
|
||||
|
||||
//sOptions.Add("General.ReadAttributes", "false");
|
||||
//sOptions.Add("General.ReadConstructionAndReferences", "true");
|
||||
//sOptions.Add("General.ReadActiveFilter", "true");
|
||||
//sOptions.Add("Assembly.UseRootDirectory", "true");
|
||||
//sOptions.Add("Assembly.RootDirRecursive", "true");
|
||||
//sOptions.Add("Assembly.SearchDir[0].PhysicalPath", "C:\\temp\\");
|
||||
//sOptions.Add("Assembly.SearchDir[0].Recursive", "C:\\temp\\");
|
||||
//sOptions.Add("Assembly.SearchDir[1].PhysicalPath", "C:\\temp2\\");
|
||||
//sOptions.Add("Assembly.SearchDir[1].Recursive", "true");
|
||||
|
||||
//sOptions.Add("Specifics.CatiaV4.RootDirLogicalName", "LogicalNameSample");
|
||||
//sOptions.Add("Specifics.CatiaV4.AllowSearchInOtherLogicalNames", "true");
|
||||
|
||||
bool bIsProEFile = m_pExchange.IsProEFile(InputCADFile);
|
||||
//m_pExchange.SetUnit(1.0); means mm
|
||||
m_pcFileName = InputCADFile;
|
||||
m_iProgressBareSize = 0;
|
||||
if (!m_pExchange.ConvertToXT(InputCADFile, OutputXTFile, sOptions))
|
||||
{
|
||||
Console.WriteLine("ConvertToXT failure");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//##############################################################################################################
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
String thismodulefilenamestr = System.IO.Path.GetFullPath(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
Console.Write("\nUsage:\n " + thismodulefilenamestr + " <input CAD file> <output XT file> [-LogFile logfile] [-WriteBlankedEntities]\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bWriteBlankedEntities = false;
|
||||
string LogFile = "";
|
||||
int iArg;
|
||||
for (iArg = 0; iArg < args.Length; iArg++)
|
||||
{
|
||||
if (args[iArg] == "-WriteBlankedEntities")
|
||||
bWriteBlankedEntities = true;
|
||||
if (args[iArg] == "-LogFile")
|
||||
LogFile = args[iArg + 1];
|
||||
}
|
||||
if (stTranslate(args[0], args[1], LogFile, bWriteBlankedEntities))
|
||||
Console.Write(args[1] + " has been created.\n");
|
||||
else
|
||||
Console.Write("Error: " + args[1] + " was not created.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/***********************************************************************************************************************
|
||||
*
|
||||
* Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.
|
||||
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
||||
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
||||
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
||||
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
|
||||
* scope and manner of such use.
|
||||
*
|
||||
***********************************************************************************************************************/
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ConsoleApplication")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Tech Soft 3D")]
|
||||
[assembly: AssemblyProduct("ConsoleApplication")]
|
||||
[assembly: AssemblyCopyright("Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("fb882bdf-689e-498c-9251-5b27e5c06a53")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user