//查询函数
Sub Search()
Dim oSearchService As SearchService //定义查询服务对象
Set oSearchService = CATIA.GetSessionService("Search") //从会话中获取查询对象
Dim oDatabaseSearch As DatabaseSearch //定义查询结果存储对象
Set oDatabaseSearch = oSearchService.DatabaseSearch //从服务中获取对象
oDatabaseSearch.BaseType = "VPMReference"//设置目标对象类型
oDatabaseSearch.AddEasyCriteria "V_Name", "Ship*" //设置过滤器
oSearchService.Search //执行查询服务
End Sub
//打开查询结果对象
Sub OpenData(oSearchService)
Dim cPLMEntities As PLMEntities //定义实体对象集合
Set cPLMEntities = oDatabaseSearch.Results//从查询结果中获取实体对象
Dim oPLMOpenService As PLMOpenService
Set oPLMOpenService=CATIA.GetSessionService("PLMOpenService") //获取打开服务
Dim oEditor As Editor //定义当前活动编辑器
Dim oPLMEntity As PLMEntity
For Each oPLMEntity In cPLMEntities //遍历对象集合
oPLMOpenService.PLMOpen oPLMEntity, oEditor
Next
End Sub