3D PLM PPR Hub Open Gateway |
Process Modeler |
Creating a Library of ActivitiesDefining activities |
Use Case |
AbstractThis article accompanies the CAADmiGenerLibrary use case. This use case explains how to create new activities and store them in a special library document used to define processes. |
This use case is intended to help you create a new activities library and store new activity types in it. Specifically, you will learn how to:
[Top]
CAADmiGenerLibrary is a use case of the CAADMAPSInterfaces.edu framework that illustrates DMAPSInterfaces framework capabilities.
[Top]
The goal of CAADmiGenerLibrary is to illustrate the creation of a new
activities library. It creates the library as a ProcessLibrary
type
of document, retrieves its root container as a CATISPPActivityTypeFactory
and creates several new activity types. It then simply saves the new catalog
document and ends the session.
[Top]
To launch CAADmiGenerLibrary, you will need to set up the build time environment, then compile CAADmiGenerLibrary along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1].
To launch the use case, execute the following command:
mkrun -c "CAADmiGenerLibrary LibraryName.act"
[Top]
CAADmiGenerLibrary code is located in the CAADmiGenerLibrary.m use case module of the CAADMAPSInterfaces.edu framework:
Windows | InstallRootDirectory/CAADMAPSInterfaces.edu/CAADmiGenerLibrary.m |
Unix | InstallRootDirectory\CAADMAPSInterfaces.edu\CAADmiGenerLibrary.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a unique source file named CAADmiGenerLibrary.cpp.
[Top]
There are three logical steps in CAADmiGenerLibrary:
We will now comment each of these sections by looking at the code.
[Top]
HRESULT rc = E_FAIL; ... CATSession *pSession = NULL; rc = ::Create_Session("CAA2_Sample_Session", pSession ); |
Generally, the first thing that is necessary in a batch program is the
creation of a new session. This is done using the Create_Session
global function. It is important not to forget to delete the session at the
end of your batch program.
CATDocument *pActDoc = NULL; rc = CATDocumentServices::New("ProcessLibrary", pActDoc ); if ( FAILED(rc) || (NULL==pActDoc) ) return 2; |
Now that we have a current session, we can create a new activities
library which is simply a new document of type ProcessLibrary
.
This is done using the CATDocumentServices::New
method.
Note that ProcessLibrary
is the name that appears in the list
of document types available seen in the File/New
menu of an
interactive session. The actual suffix of the document is .act
.
[Top]
CATInit *pInitOnDoc = NULL; rc = pActDoc -> QueryInterface (IID_CATInit, (void**) &pInitOnDoc); if (FAILED(rc)) return 6; CATISPPActivityTypeFactory *piRootActivity = (CATISPPActivityTypeFactory* ) pInitOnDoc->GetRootContainer("CATISPPActivityTypeFactory"); if ( NULL == piRootActivity ) return 3; pInitOnDoc -> Release(); pInitOnDoc = NULL; |
We get a CATISPPActivityTypeFactory handle from the root container
of the new activities library document using CATInit::GetRootContainer
.
CATISPPActivityType_var spAssemblyActvity = piRootActivity->CreateActivityType("CAADmiAssembly"); CATISPPActivityType_var spPlaceActivity = piRootActivity->CreateActivityType("CAADmiPlace"); piRootActivity -> Release(); piRootActivity = NULL; |
Using the CATISPPActivityTypeFactory handle, we create two kinds of activities: "CAADmiAssembly" that will be used to assemble objects, and "CAADmiPlace" that will be used to position objects. Generally, try to choose activity names in order to avoid all confusion between activities.
[Top]
rc = CATDocumentServices::SaveAs(*pActDoc, argv[1]); if ( FAILED(rc) ) return 4; // remove opened document rc = CATDocumentServices::Remove (*pActDoc); if (!SUCCEEDED(rc)) return 5; // delete the session, removes the opened documents also. // never forget to delete a creating session after usage. rc = ::Delete_Session("CAA2_Sample_Session"); |
The activities library document is saved under the name passed as an argument
to this program, using the SaveAs
static method of CATDocumentServices.
Also, it is a good idea to always remove the document from the session using the
Remove
static method of CATDocumentServices. Do not forget
to delete the session using the Delete_Session
global function.
[Top]
This use case has shown you how to:
New
static method of CATDocumentServicesCreateActivityType
method of the CATISPPActivityTypeFactory interface, whose handle is
retrieved using the GetRootContainer
method of CATInitSave
and Remove
static methods of CATDocumentServices.[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Apr 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.