How to list the libraries and models in Model Mart through the API?

353 Views Asked by At

I have written a Python script that loops through the file system and lists all of the Erwin files that I find. I then process these files in some fashion and save the results. I'm now trying to do the same thing with the repository. I can open a model if I know its full path, but I want to dynamically build the list and iterate though the models. Can anyone tell me where to start, or has anyone found VB code that does some of this? The Erwin samples assume you know the complete name of the model that you want to open/save.

Thanks in advance; Jeff

1

There are 1 best solutions below

0
On

Assumes you know path to Mart's folder; if not, use wildcard * to traverse folders e.g. LocateDirectory("mart://Mart/*", "")

# get list of models in Mart's folder
api = win32com.client.Dispatch("erwin9.SCAPI")
model_directories = api.ModelDirectories
mart = model_directories.Add("mart://Mart?your-connection-details-here")
lib = mart.LocateDirectory("mart://Mart/your-path-to-mart-folder-here", "")
unit = lib.LocateDirectoryUnit("*", "")
while unit:
    print(unit.Name)
    unit = lib.LocateDirectoryUnitNext()