korbn
September 21, 2021, 11:31am
1
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
bnemec
September 22, 2021, 3:37pm
2
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.
korbn
September 23, 2021, 7:24am
3
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…
bnemec
September 23, 2021, 1:05pm
4
Does the user logged in when running/debugging have permissions to overwrite version? APIs still follow the rules.
korbn
September 23, 2021, 1:33pm
5
I tried it through Admin with all permissions, and result is the same. new version when check-in.
bnemec
September 23, 2021, 1:40pm
6
so what combination, exactly, of flags are you using?
korbn
September 23, 2021, 1:57pm
7
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…
bnemec
September 23, 2021, 2:53pm
8
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
korbn
September 23, 2021, 4:10pm
9
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
bnemec
September 23, 2021, 4:12pm
10
I learned something new too.
Please mark thread as solved.
bnemec
September 27, 2021, 3:19pm
12
Or like a blind squirrel…
I just hope I’m more help than hindrance when I try to give back.