Home PDM/PLM Creating, Opening, and Saving Files

Creating, Opening, and Saving Files

Welcome back! This is Part 2 in this series of blog posts, and here I will explain how to work with the 3DEXPERIENCE (3DX) database content.

First of all, Dassault doesn’t like to use the word “file” when we talk about 3DX. As you might very well be aware, all of the 3DX content is stored in the DB, and each and every item in that DB is now called a “PLM Entity”. (Mind you, in the end there’s a file for every item in the DB, stored somewhere on a server.) Still, from here on, we will use the words “PLM entity” or “PLM object” for every item in that DB.

This is probably one of the biggest differences between V5 and 3DX.

Document-based vs. DB-based

V5 is document-based. When you see a model on your screen in V5, it’s represented by two things – the Document object and the Window object. When you open or save a model in V5, CATIA actually either reads or saves a file.

Figure 1

What you see on the 3DX screen is also represented by two things, but now it’s the Editor object and the Window object. The Window object performs the same function as in V5, which is displaying the model on the screen. The Editor object’s role, however, is that of the “controller” for the model’s content. I.e., it holds the current app and maintains the list of all the commands that can be launched from the app.

The Editor has a property ActiveObject, which is the object that you see on the screen. To get a hold of the active object, you could use the following commands in VBA, and from there on work with it.

01: Dim oActiveObj As AnyObject

                02: Set oActiveObj = CATIA.ActiveEditor.ActiveObject

The content object corresponds to a PLM Entity in the DB, which is represented by a meta-data card and a storage file. Which creates an “extra layer” between 3DX session and the files in the DB. To get the file, the system first reads the meta-data, which tells where exactly the file is located.

Figure 2

In 3DX you can’t just “open” or “save” the model. You have to ask a 3DX “service” to do it for you.

I’ll be discussing in detail the 3DX “services” in part 3 of the series, so for now we’ll keep it simple.

Searching and Opening from the DB

To bring a model into 3DX session, you must search for it first (SearchService), then open it (PLMOpenService). The VBA code would look something like this:

‘ Get the SearchService object and create search query

01: Dim oSearchService As SearchService

02: Set oSearchService = CATIA.GetSessionService(“Search”)

03: Dim oDBSearch As DatabaseSearch

04: Set oDBSearch = oSearchService.DatabaseSearch

05: oDBSearch.BaseType = “VPMReference“                                       ‘ searches for a PhysicalProduct

06: oDBSearch.AddEasyCriteria “V_Name”, “<model_title>”      ‘ searches using the Title

‘ Launch the search

07: oSearchService.Search

‘ Retrieve the list of found entities

08: Dim cPLMEntities As PLMEntities

09: Set cPLMEntities = oDBSearch.Results

‘ Get the PLMOpen service & open the first found entity

10: Dim oPLMOpenService As PLMOpenService

11: Set oPLMOpenService = CATIA.GetSessionService(“PLMOpenService”)

12: Dim oEditor As Editor

13: oPLMOpenService.PLMOpen cPLMEntities.Item(1), oEditor

Saving to the DB

To save the current model in the DB, you would have to use the PLMPropagateService. The VBA code would look something like this:

‘ Get the PropagateService object

01: Dim oSaveService As PLMPropagateService

02: Set oSaveService = CATIA.GetSessionService(“PLMPropagateService”)

 ‘ Save to DB (only saves content of the Active Editor!)

03: oSaveService.PLMPropagate

Creating new Content

Now, to create new content, you would have to use yet another Service – PLMNewService.

01: Dim oServ As PLMNewService

02: Set oServ = CATIA.GetSessionService(“PLMNewService”)

03: Dim oEditor As Editor

04: oServ.PLMCreate “<content_type>”, oEditor

The <content_type> string can have the following values:

  • “Drawing”: Creates a Drawing
  • “3DShape”: Creates a 3D Shape
  • “3DPart”: Creates a 3D Part
  • “VPMReference”: Creates a Physical Product

Here’s the bad news – creating a new 3D Part or a Physical Product from a macro requires a special license, either VMX or E70. Without the license, you can create either a Drawing or a 3D Shape only. Typically, most companies don’t have this license, which means – don’t expect to be able to create a new 3D Part or a Physical Product using scripting!