Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

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

umakant.sontakke
Participant

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

umakant.sontakke
Participant
Participant

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

 

0 Likes
Reply
Accepted solutions (1)
650 Views
6 Replies
Replies (6)

sundars
Autodesk
Autodesk

Hi @umakant.sontakke 

 

You could try move the step-addin activation/deactivation only once per startup. Is there a reason to deactivate it everytime you translate?

 

It also depends on how big your parts are, where the step files are being created and saved etc (network/local). 

You could also debug your code and watch the task manager and see where the memory spike is.

 

Final note, if you are using inventor step translators, they should automatically do a demand load and activate when you save copy as step.

 

If nothing works, please share your addin code along with sample parts files and we can take a look.

 

Thanks

-shiva

 

Shiva Sundaram
Inventor Development
0 Likes

Frederick_Law
Mentor
Mentor

Did you try Task Scheduler?

0 Likes

umakant.sontakke
Participant
Participant

Hi @sundars ,

 

Thanks for your response.

As you suggested , I have activated & deactivated step addin only once.

But as no such improvement in performance.

So we are creating step file form network .

I have shared code & files .

please let us know your reply.

 

Thanks in advance,

Umakant

0 Likes

sundars
Autodesk
Autodesk
Accepted solution

Hi @umakant.sontakke 

 

I am afraid, I cannot compile your sources without all the necessary libraries. Instead, what I would recommend is try to debug it yourself and see where its hanging?

 

1. First, try to see if you can translate using a local machine and measure the speed

2. If it works fine BUT translating it off a network is slow, then its most likely related to network issues

3. If local machine translation is slow, then you would need to debug it line by line and see where its taking up time

4. You could also try manually translating it using Inventor and see if that takes time.

 

The  sample part file you enclosed seems straightforward and exports to step very fast.

 

Thanks

-shiva

 

Shiva Sundaram
Inventor Development
0 Likes

umakant.sontakke
Participant
Participant

Hi @sundars ,

Thanks for your response.

As you said,

1)it's taking time when accessing file from network & saving it on network.

2)Also , this conversion is depend on file size.

3)we are creating CGR's also , so CGR creation is taking much time.

4)So , on local it's really taking very less time.

 

Thanks for your time. much appreciated.

 

 

Thanks & Regards,

Umakant

 

 

sundars
Autodesk
Autodesk

Hi Umakant,

 

Thank you for the update! Glad that you nailed down the root cause. If possible you could translate locally and then copying the results back to the network server to speed up things. 

 

Regards

-shiva

Shiva Sundaram
Inventor Development
0 Likes