Hi everybody,
I have to create a software to migrate Inventor's documents from an old version to a new version.
I wrote all code in C# and all work fine except 1 file of skeleton.
Attached you can download an Pack and go thath contains the models.
My code is simple, I open a file and save it but if I try to do the save with "TUR_ASM00061_Skeleton.ipt" I get an exception.
I tryied to save starting from parent assembly (TUR_ASM00061_GT.iam) using save 2 but I get no result.
I tryied to modify the "TUR_ASM00061_Skeleton.ipt" and save and nothing.
A piece of my code
try
{
inventorService.GetInventor().SilentOperation = true;
document.Save();
}
catch (Exception)
{
nonMigrati.Add(fm);
}
Someone can help me to solve this problem?
P.s. If I open the TUR_ASM00061_GT.iam and perform save all manualy all is migrated correctly
Thanks a lot.
Solved! Go to Solution.
Solved by infoQN6A6. Go to Solution.
I tryed to write a simple code in vba and by vba it is working.
I opened the TUR_ASM00061_Skeleton.ipt and started the code and it is copied correctly the file. The problem is only by my app (it is an .exe)
Public Sub a()
Set doc = ThisApplication.ActiveDocument
Call doc.SaveAs("C:\Workarea\TestProgrammazione\Archivio\Prove valerio\Test\TUR_ASM00061\Frame\TUR_ASM00061_Skeleton_1.ipt", True)
End Sub
Some suggestion?
In .net code, Save() method is used to save the file. But, SaveAs() API call is used in VBA code. Try SaveAs() API in C# code and test the result.
Thanks and regards,
Chandra shekar G
Thanks for your reply.
In C# I tried Save and SaveAs (changing parameters) and never works on skeleton document. If I use the same methods on other files I have no problem
Please provide non confidential complete C# code.
Thanks and regards,
var migra = new Action<Document, FileModelMigrazione>((document, fm) =>
{
contatore++;
App.Current.Dispatcher.BeginInvoke(new Action(() =>
{
PercentualeDiAvanzamento = contatore / totale * 100;
MessaggioAttività = $"Migro il documento {(fm == null ? "" : fm.FileName)}";
}));
if (inventorService.InventorStaRispondendo() == false)
{
inventorService.ArrestaERiavvia();
inventorService.GetInventor().SilentOperation = true;
document = inventorService.GetInventor().Documents.Open(fm.FullFileName);
}
if (fm == null)
{
return;
}
if (fm.SolaLettura)
{
fm.RimuoviSolaLettura();
}
try
{
inventorService.GetInventor().SilentOperation = true;
document.Save();
}
catch (Exception)
{
nonMigrati.Add(fm);
}
_daMigrare.Remove(fm);
});
You can see the save method in the try catch.
I tried to modify the code and to use Save2(true) or Save2(true, collection of skeletons file) but nothing change
Hi all,
I found a solution.
Skeleton.ipt cannot be saved out of its parent assembly and save2 method doesn't save the skeleton.ipt if it is no dirty. My solution is modify description property and rewrite the old description in the skeleton.ipt. This action modifies the dirty property to true and now Save2 method will save the parent assembly and the skeleton.ipt file.
Can't find what you're looking for? Ask the community or share your knowledge.