Vault process automation synchronize properties/change lifecycle- C#

Vault process automation synchronize properties/change lifecycle- C#

m_baczewski
Advocate Advocate
1,576 Views
11 Replies
Message 1 of 12

Vault process automation synchronize properties/change lifecycle- C#

m_baczewski
Advocate
Advocate

Hi,

I'm developing a configurator integrated with the ERP system, which generates a model based on user-entered data, creates drawings, and then inputs all the elements into Vault.

I'm familiar with the Inventor API in general, but now I need to work with Vault, and unfortunately, I'm not familiar with its API. That's why I'm asking: Is it possible to perform these steps in Vault through the API:

  1. Synchronize assembly properties along with dependent elements.
    m_baczewski_0-1715083698111.png

     

  2. Wait until the synchronization is completed.
  3. Change the Lifecycle to "Documentation Ready."
  4. Wait again until everything is done.
  5. Assign the item.

m_baczewski_2-1715083838533.png

6.Change the Number in the Item.

m_baczewski_3-1715083995432.png

 

7.Save the element.

m_baczewski_4-1715084029517.png

 

8.Finally, go to the components list (BOM) in Item and change lifecycle to "For review."

m_baczewski_5-1715084410743.png

 

I would appreciate any help or tips. Where can I find materials on this?

Thank you!

0 Likes
1,577 Views
11 Replies
Replies (11)
Message 2 of 12

Markus.Koechl
Autodesk
Autodesk

I think you should implement steps 1 and 2 listed above, integrated with your model/drawing creation in Inventor. You need to call the Inventor user command "VaultCheckInTop" to add the newly created files, including the CAD BOM, to Vault. A property synchronization should be unnecessary if you pre-populate all properties during the model/drawing creation. The post-event of the AddFiles action (the initial check-in will fire the AddFile rather than the Check-in) can be your starting point for the subsequent steps. This event can also be the starting point for consuming Vault API. To get started, I recommend reading the latest Blog post series Vault SDK Getting Started: Vault Customization Archives - Under the Hood - All things PDM and PLM (autodesk.com)



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 12

m_baczewski
Advocate
Advocate

Thanks for the response. I use the "VaultCheckInTop" method during model and drawing generation, but unfortunately, even after this operation, I have inconsistent properties, and only synchronization helps.

m_baczewski_0-1715147088275.png

 

Is it possible to perform synchronization in such a way that it doesn't involve the Job Processor?

0 Likes
Message 4 of 12

Markus.Koechl
Autodesk
Autodesk

What properties are not compliant? Are these missing values, or are Vault systems properties to be written back into the file? You can implement an update properties function, but I recommend avoiding additional synchronization: Knowing the properties that will be missed for new files, your automation should be enabled to read these before check-in and write them into the iProperties. Then, a check-in is sufficient. To read properties, you can re-use the existing Vault connection. You can review a fully coded sample, as we had an open-source tech preview for the iLogic-Vault integration before Inventor 2024 implemented this as a default. If your automation leverages iLogic anyway, you have all you need there.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 12

m_baczewski
Advocate
Advocate

In my case, the inconsistent property is the first creation date, which does not match the creation date.

m_baczewski_0-1715156666246.png

m_baczewski_1-1715156795374.png

 

0 Likes
Message 6 of 12

Markus.Koechl
Autodesk
Autodesk

I guess (due to localization ;)), you are writing back the "Original Create Date" (Vault System Property) that differs from the file's creation date. A post-event handler for AddFile could do the action instead of a job to get this synchronized automatically.

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 7 of 12

m_baczewski
Advocate
Advocate

Okay, I understand. Isn't it the case that by using AddFile, files being placed in Vault lose their connection to the parent?

Initially, I used this solution and for now, it's working fine: https://forums.autodesk.com/t5/vault-customization/syncing-vault-properties/m-p/9762768#M8857

0 Likes
Message 8 of 12

Markus.Koechl
Autodesk
Autodesk

I did not say you should use the AddFile method rather than leveraging the AddFile post-event. The files added via the Inventor command manager "VaultCheckInTop" will capture all references properly and fire this event.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 9 of 12

m_baczewski
Advocate
Advocate

I understand now, but I'm not sure why in my case the Inventor command manager "VaultCheckInTop" doesn't cause the properties to be updated during CheckIn. Property inconsistency only occurs in drawings. I'm using Inventor Professional 2022.

 

It looks like this:

Public Static void VaultCheckIn(Inventor.Application invApp, int sleepTime)
{
    Process[] inventorProcess = Process.GetProcessesByName("Inventor"); // ustawia okno inventora na aktywne, w innym wypadku nie wpisze Do vaulta pozniej usunę //temporary
    SetForegroundWindow(inventorProcess[0].MainWindowHandle);

    Inventor.ControlDefinition oControlDef;
    oControlDef = invApp.CommandManager.ControlDefinitions["VaultCheckinTop"];
    oControlDef.Execute2(False);

    System.Windows.Forms.SendKeys.SendWait("\t\n"); // nie bedzie potrzebne jezeli w ustawieniach inventora wylaczymy wyskakujace okno od Vaulta //temporary
    System.Threading.Thread.Sleep(sleepTime);
}

 

0 Likes
Message 10 of 12

m_baczewski
Advocate
Advocate

I found another way to synchronize properties, it looks quite comical.

 

 Public Static void VaultCheckIn(Inventor.Application invApp, int sleepTime)
{
    Process[] inventorProcess = Process.GetProcessesByName("Inventor"); // ustawia okno inventora na aktywne, w innym wypadku nie wpisze Do vaulta pozniej usunę //temporary
    SetForegroundWindow(inventorProcess[0].MainWindowHandle);

    Inventor.ControlDefinition oControlDef;
    oControlDef = invApp.CommandManager.ControlDefinitions["VaultCheckinTop"];
    oControlDef.Execute2(False);
    System.Windows.Forms.SendKeys.SendWait("\t\n"); // nie bedzie potrzebne jezeli w ustawieniach inventora wylaczymy wyskakujace okno od Vaulta //temporary

    System.Threading.Thread.Sleep(sleepTime);

    oControlDef = invApp.CommandManager.ControlDefinitions["VaultPropertyWriteBack"];
    oControlDef.Execute2(False);
    System.Windows.Forms.SendKeys.SendWait("\n");
    System.Threading.Thread.Sleep(2000);
    invApp.ActiveDocument.Save();
    invApp.ActiveDocument.Save();

    oControlDef = invApp.CommandManager.ControlDefinitions["VaultCheckinTop"];
    oControlDef.Execute2(False);
    System.Windows.Forms.SendKeys.SendWait("\t\n");

    System.Threading.Thread.Sleep(sleepTime);
}

 

0 Likes
Message 11 of 12

Markus.Koechl
Autodesk
Autodesk

You could better call the check-in synchronously (enable dialog suppression in Vault Options): 

oControlDef = invApp.CommandManager.ControlDefinitions["VaultCheckinTop"];
    oControlDef.Execute2(True); 

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 12 of 12

m_baczewski
Advocate
Advocate

Yes, at the moment I'm handling a few things and sometimes I need the Vault window in Inventor, but once I deploy the application to the server, I'll change it to look like this: oControlDef.Execute();

 

@Markus.Koechl 

Thanks for helping me solve one problem,I'll come back when a new problem arises.🙂

0 Likes