How to use a macro to open data in V6

In CATIA V5, if you know the file path of existing data, you can open it using a CATVBA or CATScript macro like this:

Dim sIdentifier As String

sIdentifier=”E:/myDocument.CATProduct”

Dim oProductDocument As ProductDocument

Set oProductDocument = CATIA.Documents.Open(sIdentifier)

In 3Dexperience, we need to search a database instead:

Dim oSearchService As SearchService

Set oSearchService = CATIA.GetSessionService(“Search”)

Dim oDBSearch As DatabaseSearch

Set oDBSearch = oSearchService.DatabaseSearch

oDBSearch.BaseType = “VPMReference”

oDBSearcg.AddEasyCriteria “V_Name”, “myDocument”

oSearchService.Search

Dim cPLMEntities As PLMEntities

Set cPLMEntities = oDBSearch.Results

Dim oPLMOpenService As PLMOpenService

Set oPLMOpenService = CATIA.GetSessionService(“PLMOpenService”)

Dim oEditor As Editor

Dim oPLMEntity As PLMEntity

For Each oPLMEntity In oPLMEntities

Set oEditor = oPLMOpenService.PLMOpen(oPLMEntity)

Next

That’s it! If you’ve used something like this before, let us know in the comments below!

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.