3D PLM PPR Hub Open Gateway

Process Modeler

Creating a Library of Activities

Defining activities
Use Case

Abstract

This 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.


What You Will Learn With This Use Case

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]

The CAADmiGenerLibrary Use Case

CAADmiGenerLibrary is a use case of the CAADMAPSInterfaces.edu framework that illustrates DMAPSInterfaces framework capabilities.

[Top]

What Does CAADmiGenerLibrary Do

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]

How to Launch CAADmiGenerLibrary

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]

Where to Find the CaaDmiGenerLibrary Code

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]

Step-by-Step

There are three logical steps in CAADmiGenerLibrary:

  1. Creating a New Activities Library Document
  2. Creating Activity Types
  3. Saving the Activities Library Document

We will now comment each of these sections by looking at the code.

[Top]

Creating a New Activities Library Document

  1. Create the session
    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.

  2. Create activities library
    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]

Creating Activity Types

  1. Retrieve activities library document root container
    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.

  2. Create activity types
    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]

Saving the Activities Library Document

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]


In Short

This use case has shown you how to:

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Apr 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.