Logos Technologies It Department

Using IEdmBatchUnlock and Python

Discussion created by Logos Technologies It Department on Feb 17, 2020

I recently took a crack at doing some PDM scripting in Python using the PDM API. I started by following the directions here: EPDM API Python Implementation. It was actually surprisingly straightforward to get something working that would check out a bunch of files, update some variables, and check them back in. The only downside is that the code is a little slow. I was hoping to fix that by IEdmBatchUnlock interface described here: 2019 SOLIDWORKS API Help - IEdmBatchUnlock Interface. This is where I started to run into trouble. I was able to perform the first step in the procedure recommended in the aforementioned documentation

 

from pdm_lib import *

 

vault = EdmVault5()
vault.Login(username, pw, v_name) #connect to vault

unlocker = vault.CreateUtility(6) #create IEdmBatchUnlock object

 

According to python, this produces an object of type "pdm_lib.IEdmBatchUnlock," which seems like it's right. However, when I attempt to call the AddSelection method, python throws an error because it can't find that method for this object type. When I look in the pdm_lib.py file, this is what I see for the IEdmBatchUnlock class (sorry about the janky formatting, not sure if it's possible to do code blocks in this post)): 

 

class IEdmBatchUnlock(DispatchBaseClass):
   'IEdmBatchUnlock Interface'
   CLSID = IID('{748E6759-E16D-4F69-A0BC-98A9A9F2E650}')
   coclass_clsid = None

 

   _prop_map_get_ = {
   "Comment": (5, 2, (3, 0), ((16392, 10),), "Comment", None),
   }
   _prop_map_put_ = {
   "Comment": ((5, LCID, 4, 0),()),
   }
   def __iter__(self):
      "Return a Python iterator for this object"
   try:
      ob = self._oleobj_.InvokeTypes(-4,LCID,3,(13, 10),())
   except pythoncom.error:
      raise TypeError("This object does not support enumeration")
      return win32com.client.util.Iterator(ob, None)

 

I don't see a reference to the "AddSelection" method here or anywhere else in pdm_lib.py, so I'm not surprised Python is throwing errors. Is there some way to access this method? Or is the problem that I'm trying to do this with python and should really be using VB or C?

Outcomes