3D PLM Enterprise Architecture |
Data Access - File |
Loading a DocumentWorking with existing documents |
Use Case |
AbstractThis article accompanies the CAAOmbLoadDoc use case. This use case explains how to load and save an existing document. |
This use case is intended to help you make your first steps in working with documents. Basically, you will learn how to:
Before getting to the use case itself, it is important to get an understanding of what documents are. This is the goal of the next section. You can skip it and get directly to the use case if you are already familiar with these concepts.
[Top]
The document concept allows users to gather objects which have something in common, to display them in a document window when in interactive mode, and to save them in a storage unit under a unique storage name for future retrieval.
Objects that are created and manipulated in similar ways are grouped in the same type of document. In CAA V5 interactive mode, to create and manipulate objects, you are provided with workshops. A document type is associated with one or more workshops. For example, when you create a Part document, you are provided with the Sketcher and PartDesign workshops by which you can create and manipulate objects named "parts". All these parts are then regrouped within one or more graphic windows (when in interactive mode) which symbolize a Part document.
CATIA documents are not only the places where related objects reside, they are also persistency units which can be exchanged between users.
[Top]
CAAOmbLoadDoc is a use case of the CAAObjectModelerBase.edu framework that illustrates ObjectModelerBase framework capabilities.
[Top]
The goal of CAAOmbLoadDoc is to load an existing document and to save and remove it from the session.
[Top]
To launch CAAOmbLoadDoc, you will need to set up the build time environment, then compile CAAOmbLoadDoc along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1]. When launching the use case, you must pass the following arguments:
[Top]
CAAOmbLoadDoc code is located in the CAAOmbLoadDoc.m use case module of the CAAObjectModelerBase.edu framework:
Windows | InstallRootDirectory\CAAObjectModelerBase.edu\CAAOmbLoadDoc.m |
Unix | InstallRootDirectory/CAAObjectModelerBase.edu/CAAOmbLoadDoc.m |
where InstallRootDirectory
is the root directory of your CAA
V5 installation. It is made of a unique source file named CAAOmbLoadDoc.cpp.
[Top]
There are two logical steps in CAAOmbLoadDoc:
We will now comment each of those sections by looking at the code.
[Top]
char *sessionName = "CAA2_Sample_Session"; CATSession *pSession = NULL; HRESULT rc = ::Create_Session(sessionName, pSession); if ((FAILED(rc)) || (NULL == pSession)) { cout << "ERROR in creating session" << endl << flush; return 1; } |
Since this is a batch program, it is first necessary to open a new
session before beginning to work with documents. Do not forget that this
session needs to be deleted at the end of the program. Never open more than
one session for any given batch program! To open a new session, use the
Create_Session
global
function.
CATDocument *pDoc = NULL; rc = CATDocumentServices::OpenDocument(argv[1], pDoc); if (SUCCEEDED(rc) && (NULL != pDoc)) cout << "Document opened OK" << endl << flush; else { cout << "ERROR in opening an existing document" << endl << flush; return 2; } |
Now that the session is opened, you can load an existing document using
the OpenDocument
static method of CATDocumentServices.
This method requires, as a first parameter, the entire
storage path name and document name of the existing document that we want
to load into the session. In this use case, we enter this information as an
argument to the program. The second parameter of the Open
method returns a CATDocument pointer to the document it has loaded.
Once the document exists in the session, you can work with objects within it, using specific interfaces external to the ObjectModelerBase framework.
[Top]
rc = CATDocumentServices::Save (*pDoc); if (SUCCEEDED(rc)) cout << "Document saved OK" << endl << flush; else { cout << "ERROR in saving document" << endl << flush; return 3; } |
To save the new document under the same name, use the Save
static method of CATDocumentServices. This method takes the
CATDocument pointer to the document as the only parameter.
rc = CATDocumentServices::Remove (*pDoc); if (SUCCEEDED(rc)) cout << "Document removed OK" << endl << flush; else { cout << "ERROR in removing document" << endl << flush; return 4; } |
<>If you ever needed to re-open the document during this same session,
it would then be necessary to also remove it from the session after having
saved it. Otherwise, you need not worry about it since deleting the session
will automatically remove the document as well. To remove the document, you
should use the Remove
static method of CATDocumentServices.
rc = ::Delete_Session(sessionName); if (SUCCEEDED(rc)) cout << "Session deleted OK" << endl << flush; else { cout << "ERROR in deleting session" << endl << flush; return 5; } |
Do not forget to delete the session at the end of the program using the
Delete_Session
global function!
[Top]
This use case has demonstrated how to:
Open
static method of
CATDocumentServicesSave
and
Remove
static methods of CATDocumentServices.[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Feb 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.