IEdmBatchUnlock Interface

ola! how can i batch check-in with version overwrite?

in UnlockFile Method (IEdmFile5) all ok. this method have flag to overwrite version.
http://help.solidworks.com/2017/english/api/epdmapi/EPDM.Interop.epdm~EPDM.Interop.epdm.EdmUnlockFlag.html

BUT! there is no such flag in CreateTree Method (IEdmBatchUnlock)
https://help.solidworks.com/2021/English/api/epdmapi/EPDM.Interop.epdm~EPDM.Interop.epdm.EdmUnlockBuildTreeFlags.html

and IEdmBatchUnlock always create new version of file

EdmUnlockBuildTreeFlags Enumeration - 2019 - SOLIDWORKS API Help

I have not tested this but 4096 might be what you want; the terminology between API and GUI is often different for similar things. I intentionally avoid having anything I write check a file in with version overwrite. I know so little of the entirety of PDM that I don’t want to loose the ability to go back to previous version.

I already tried this flag a couple of days ago, as described. and today I tried hoping for a miracle))) but all to no avail, it still creates new versions. this script just updates the properties for me, and creating a new version every time seems superfluous… although, apparently, i will have to live with this and somehow adapt…

Does the user logged in when running/debugging have permissions to overwrite version? APIs still follow the rules.

I tried it through Admin with all permissions, and result is the same. new version when check-in.

so what combination, exactly, of flags are you using?

now only Eubtf_MayUnlock
tried:

  • Eubtf_MayUnlock + Eubtf_MayUnlockWithLatest
  • Eubtf_Nothing
  • Eubtf_MayUnlock + Eubtf_MayUnlockWithoutOverwrite

and there is always a new version…
maybe it was specially removed by the developers the possibility of overwriting during registration…

Still digging, man they didn’t make this process straight forward! Makes me wonder what it actually looks like on the other side of “The API Wall.”

Anyway, take a look at this:

EdmRefItemProperty Enumeration - 2019 - SOLIDWORKS API Help

found it from here:

SetProperty Method (IEdmRefItem) - 2019 - SOLIDWORKS API Help

from here:

IEdmRefItem Interface Members - 2019 - SOLIDWORKS API Help

from here:
GetItems Method (IEdmRefItemContainer) - 2019 - SOLIDWORKS API Help

IEdmRefItemContainer Interface - 2019 - SOLIDWORKS API Help

Example:
Prevent Admin from Checking In File Example (C#) - 2019 - SOLIDWORKS API Help

 private void UpdateBatchCheckInButton_Click(object sender, EventArgs e)
        {
             try
            {
                //Only create a new vault object
                //if one hasn't been created yet
                if (vault1 == null)
                {
                    vault1 = new EdmVault5();
                }
 
                if (!vault1.IsLoggedIn)
                {
                    //Log into selected vault as the current user
                    vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32());
                }
                   IEdmRefItemContainer container = null;
                   if (bUnlock == null)
                    {
                        MessageBox.Show("No checked-out files selected to check in. Please try again.");
                        return;
                    }
                    else
                    {
                    container = (IEdmRefItemContainer)bUnlock;
                    object[] items = null;
                    IEdmRefItem theItem = null;
                    container.GetItems(EdmRefItemType.Edmrit_All, out items);
                    int j = 0;
                    while (j < items.Length)
                    {
                        IEdmRefItem aItem = null;
                        theItem = (IEdmRefItem)items[j];
                        aItem = theItem;
                        object value = null;
                        **aItem.SetProperty(EdmRefItemProperty.Edmrip_CheckKeepLocked, value);**
                        j = j + 1;
                    }
	     }
                    MessageBox.Show("Check-in flags updated.");
             }
                
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + "\n" + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
 
        }
4 Likes

thank you very much!
I hope this discussion will help someone else too!)
I just added block from example, replaced the line with this:

aItem.SetProperty(EdmRefItemProperty.Edmrip_CheckOverwriteLatestVersion, (object)true);

and everything worked! versions overwrited successfully!!!

1 Like

I learned something new too.

Please mark thread as solved.

Answered like a boss! :sunglasses: :sunglasses: :sunglasses: :sunglasses:

1 Like

Or like a blind squirrel… :wink:

I just hope I’m more help than hindrance when I try to give back.