Enterprise Architect:GetBaselines 在 python 中不起作用
Enterprise Architect: GetBaselines does not work in python
我编写了一个 Python 函数来从 PackageGUI 中检索基线:
def get_baselines(pkgguid):
""" Get list of baselines for package """
rep = win32com.client.Dispatch("EA.App").Repository
rep.GetPackageByGuid(pkgguid) # Works
print("pgkname: ", pkg.Name) # This works
project = rep.GetProjectInterface() # Works
print ("guid xml: ", project.GUIDtoXML(pkgguid), "GUID: ", pkgguid) # Works
pkgxml = project.GetBaselines(project.GUIDtoXML(pkgguid)) # Throws Error
print (pkgxml) # Not reached
这会导致错误:
File "C:\devel\EnterpriseArchitect\ea_scripts\dbops.py", line 44, in get_baselines
pkgxml = project.GetBaselines(project.GUIDtoXML(pkgguid))
File "<COMObject GetProjectInterface>", line 3, in GetBaselines
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1)
我之前没有使用过任何Project Interface,所以可能是输入格式有误?
project.GetBaselines
接受两个String类型的参数,而你只传递了一个参数。
参见 the documentation
GetBaselines (string PackageGUID, string ConnectString)
String
Notes: Returns a list (in XML format) of Baselines associated with the
supplied Package GUID.
Parameters:
- PackageGUID: String - the GUID (in XML format) of the Package to get
Baselines for
- ConnectString: String - not currently used
所以你需要这样称呼它:
pkgxml = project.GetBaselines(project.GUIDtoXML(pkgguid), "")
我编写了一个 Python 函数来从 PackageGUI 中检索基线:
def get_baselines(pkgguid):
""" Get list of baselines for package """
rep = win32com.client.Dispatch("EA.App").Repository
rep.GetPackageByGuid(pkgguid) # Works
print("pgkname: ", pkg.Name) # This works
project = rep.GetProjectInterface() # Works
print ("guid xml: ", project.GUIDtoXML(pkgguid), "GUID: ", pkgguid) # Works
pkgxml = project.GetBaselines(project.GUIDtoXML(pkgguid)) # Throws Error
print (pkgxml) # Not reached
这会导致错误:
File "C:\devel\EnterpriseArchitect\ea_scripts\dbops.py", line 44, in get_baselines
pkgxml = project.GetBaselines(project.GUIDtoXML(pkgguid))
File "<COMObject GetProjectInterface>", line 3, in GetBaselines
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1)
我之前没有使用过任何Project Interface,所以可能是输入格式有误?
project.GetBaselines
接受两个String类型的参数,而你只传递了一个参数。
参见 the documentation
GetBaselines (string PackageGUID, string ConnectString)
String
Notes: Returns a list (in XML format) of Baselines associated with the supplied Package GUID.
Parameters:
- PackageGUID: String - the GUID (in XML format) of the Package to get Baselines for
- ConnectString: String - not currently used
所以你需要这样称呼它:
pkgxml = project.GetBaselines(project.GUIDtoXML(pkgguid), "")