Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Migrating skeleton by api

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
infoQN6A6
564 Views, 6 Replies

Migrating skeleton by api

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.

Valerio Pittavino
Labels (1)
6 REPLIES 6
Message 2 of 7
infoQN6A6
in reply to: infoQN6A6

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?

Valerio Pittavino
Message 3 of 7

@infoQN6A6,

 

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


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 7

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

Valerio Pittavino
Message 5 of 7

@infoQN6A6 ,

 

Please provide non confidential complete C# code.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 6 of 7

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

Valerio Pittavino
Message 7 of 7
infoQN6A6
in reply to: infoQN6A6

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.

Valerio Pittavino

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report