Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
umakant.sontakke
655 Views, 6 Replies

how to optimize performance while conversion of .ipt to step file using C# code?

Hello Experts,

 

I am trying to convert .ipt file to stp file using translator addin of inventor.

there are 2L+ objects need to convert to stp file. but it's taking very longer time to process this.

 my code is like below.

 

Inventor.TranslatorAddIn STEPAddin = null;
Inventor.Document oDocument = null;
try
{

STEPAddin = InvApp.ApplicationAddIns.ItemById["{90AF7F40-0C01-11D5-8E83-0010B541CD80}"] as TranslatorAddIn;
if (!STEPAddin.Activated)
{
STEPAddin.Activate();
}
oDocument = InvApp.ActiveDocument;
// oDocument = InvApp.Documents.Open(completefileName, false);
oDocument = InvApp.Documents.OpenWithOptions(completefileName, openFileOptions, false);

Inventor.TranslationContext oContext = InvApp.TransientObjects.CreateTranslationContext();
oContext.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism;
Inventor.NameValueMap oOptions = InvApp.TransientObjects.CreateNameValueMap();
Inventor.DataMedium oDataMedium = InvApp.TransientObjects.CreateDataMedium();
if (STEPAddin.HasSaveCopyAsOptions[oDocument, oContext, oOptions])
{
oOptions.set_Value("GeometryType", 1);
}
string NameDocument = oDocument.DisplayName;
NameDocument = NameDocument.Substring(0, NameDocument.Length - 4);
oDataMedium.FileName = outPutPath + "\\" + folder + "\\" + NameDocument + ".ipt.stp";
STEPAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium);
//sConsole.WriteLine("68 completed>>>");
string path = backupPath + "\\" + folder + "\\" + NameDocument + ".ipt.stp";
try
{
System.IO.File.Copy(oDataMedium.FileName, path, true);

}
catch (Exception ex)
{
Console.WriteLine(ex.GetBaseException());

}
partElement.SetAttributeValue("FilePath", completefileName);
partElement.WriteTo(writerOK);
strStpFilesPathInput += "\"" + oDataMedium.FileName + "\"" + "?";


}
catch (Exception ex)
{

partElement.SetAttributeValue("FilePath", completefileName);
partElement.WriteTo(writerKO);
//Console.WriteLine("220::xmlOK exception" + xmlOK.ToString());
}
finally
{

STEPAddin.Deactivate();
oDocument.Close();
}
}

 

 

with this logic only 100 objects I am able to convert per 2 to 3 mins & it also consuming too much memory.

 

 

any help on this will be very much appreciated.

 

Thanks ,

Umakant