Catalog Modeler

Creating a Catalog

Using CATICatalogChapterFactory, CATICatalogChapter, CATILinkableObject ,CATICatalogKeyword and CATICatalogDescription
Use Case

Abstract

This use case shows how to create a catalog document.


What You Will Learn With This Use Case

Users often need a way of storing and classifying the many objects they have at their disposal, whether they be screws, ball bearings or computer parts. These objects may number tens of thousands, each with its own specific characteristics such as shape, color, size, diameter, length, etc. To facilitate fast and easy retrieval of such objects thus objects avoiding time-wasting redesign Version 5 offers the possibility of creating catalogs. 

A catalog is in the form of a tree structure made up of: 

The purpose of this use case is to create a catalog composed of: 

 For components, the following articles described them more in depth:

Before getting to the use case itself, it is important to already be familiar with the basic notions of Catalog. See the referenced article [4] for a detailed overview.

[Top]

The CAACciToolCatalogCreation Use Case

CAACciToolCatalogCreation is a use case of the CAAComponentsCatalogs.edu framework that illustrates ComponentsCatalogsInterfaces framework capabilities.

[Top]

What Does CAACciToolCatalogCreation Do

This use case creates the CAATool.catalog document [Fig.1]. The scenario of its creation is explained through images created in editing the catalog thanks to the Catalog Editor workbench. At last, the interactive scenario to obtain the same result, is given. 

The goal of this catalog is to create a classification of Part documents which contain the design of Screws and Nuts.

Fig.1 The CAATool.catalog Document

The Tools chapter is the root chapter. It contains two keywords [Fig.2]:

Fig.2: The Tools's Keywords  

The Tools chapter contains three sub-chapters:

The next picture [Fig 3] shows the three lines in the Reference tab page when the Tools chapter is current in the specification tree:

Fig.3: The Tools's Reference Tab Page

For each sub-chapter the "ToolType" keyword is valuated with the following values:

Fig.4: The Tools's Keyword Tab Page

The Screws chapter is an external chapter see the column Type [Fig 3]. In fact it is the root chapter of the CAAScrew catalog created in the use case CAACciScrewCatalogCreation and detailed in the "Creating a Catalog With Part Documents" article [1]

The Nuts chapter is not an external chapter, see the column Type [Fig 3], and contains the "SideNumber" keyword. This keyword is an integer without default value (Unset in the column Value). The goal of this keyword is to separate the nuts with their number of sides. 

Fig.5: The Nuts's Keywords

This Nuts chapter contains two sub-chapters: each a Part Family [2]

The next picture [Fig 6] shows the two lines in the Reference tab page when the Nuts chapter is current in the specification tree:

Fig.6: The Nuts's Reference Tab Page

For each sub-chapter, a value for the "SideNumber" keyword is given:

Fig.7: The Nuts's  Keyword Tab Page

The Nuts6SidesFamily chapter is an external Part Family -see the column Type [Fig 6]. In fact it is a end chapter (Part family) of the CAANuts6Sides catalog created in the use case CAACciNuts6SidesCatalogCreation and explained in the "Creating a Catalog With Part Family" article [2]

The Nuts4SidesFamily chapter is a Part Family whose the Part document, with a design table, is CAANuts4Sides. Its construction is the same as the Nuts6SidesFamily Part family [2], so this article doesn't detail its creation. Nevertheless, the following picture [Fig.8] shows the descriptions for each configuration of its design table. In this same picture, notice that the Part configurations are not resolved: the value in the Type column is "Part family configuration" and not "Resolved part family configuration" and the value in the Object Name column is always CAANuts4Sides, the original Part.

Fig.8: The Nuts4SidesFamily's Reference Tab Page

The last chapter under the Tools chapter is NutsWithFixedSizeHole. This chapter contains only one chapter the Nuts6SidesHole10Family chapter [Fig 1]. This chapter is a end chapter (family) whose components will be defined by a persistent query inside the CAANuts6Sides catalog. Refer to the "Creating a Persistent Query" article [3] to have a complete explanation of this family.

The interactive scenario to obtain the same CAATool.catalog document is the following:

Launch CATIA. When the application is ready: 

(*) The file are located in the directory CAAComponentsCatalogs.edu/InputData

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

How to Launch CAACciCatalogToolsCreation

To launch CAACciToolCatalogCreation , you will need to set up the build time environment, then compile the CAACciCatalogCreate module along with its prerequisites, set up the run time environment, and then execute the use case [5]. 

mkrun -c CAACciCatalogCreate InputPath [OutputPath]

Where:

  1. InputPath : The path of files included in the directory CAAComponentsCatalogs.edu/InputData

    where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

  2. OutputPath: The path to write the created catalogs. If this path is empty, the output files are created in the current directory.

The use case creates three documents:

After its execution, you can launch CATIA and open the created catalogs or execute the CAACciCatalogNavigation use case [6] for each. This use case displays the contents of a catalog.  

[Top]

Where to Find the CAACciToolCatalogCreation Code

The CAACciToolCatalogCreation use case is made of several source files located in the CAACciCatalogCreate.m module of the CAAComponentsCatalogs.edu framework:

Name of the source file Function
CAACciCatalogCreateMain Main source file 
CAACciToolCatalogCreation  Global function to create the CAATool.catalog document
CAACciCatalogDocumentServices Global functions to factorize the code

depending on operating system you find them :

Windows InstallRootDirectory\CAAComponentsCatalogs.edu\CAACciCatalogCreate.m\
Unix InstallRootDirectory/CAAComponentsCatalogs.edu/CAACciCatalogCreate.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

There are nine logical steps in the CAACciToolCatalogCreation use case:

  1. Creating a New Catalog Document
  2. Creating the Root Chapter
  3. Creating Keywords for the Root Chapter
  4. Pointing an External Chapter
  5. Creating a Chapter to Group Together the Part Family
  6. Creating  Keyword for the New Chapter
  7. Pointing an External Family
  8. Creating a Chapter to Group Together Sub-Chapters with Persistent Query
  9. Closing the New Catalog

Some operations like create a document, save a document, retrieve a chapter,..., have been factorized in global functions described in the "Global Functions" section.

[Top]

Creating a New Catalog Document

 ...
    CATDocument * pDocument = NULL ;
    CATICatalogChapterFactory * pICatalogChapterFactory = NULL ;

    rc = ::CAACreateCatalogDocument(&pDocument,&pICatalogChapterFactory);
 ...

The CAACreateCatalogDocument global function creates a "catalog" document and returns pICatalogChapterFactory the CATICatalogChapterFactory interface pointer on its root container. This interface is necessary to create chapters.

Creating the Root Chapter 

 ...
       CATICatalogChapter * piToolChapter = NULL ;

       CATUnicodeString ChapterName = "Tools" ;
       CATBoolean IsEndChapter = FALSE ;
       rc = pICatalogChapterFactory->CreateChapter(ChapterName,IsEndChapter,piToolChapter);
       ...
 ...

The Tools chapter is created thanks to the CreateChapter method of the CATICatalogChapterFactory interface. The second parameter, IsEndChapter, specifies that the chapter is a not a family. The returned pointer, piToolsChapter, must be released as soon as it will be useless.

The Tools chapter is the first chapter created in the document, so it is the root chapter. It means that you can retrieve it thanks to the GetRootChapter method of the same interface CATICatalogChapterFactory

Creating Keywords for the Root Chapter

Creation 
 ...
       if ( SUCCEEDED(rc) && (NULL != piToolChapter))
       {
          CATICatalogKeyword * piKeyword = NULL ;
          rc = piToolChapter->AddKeyword("ToolType","String",piKeyword);
          if ( SUCCEEDED(rc) )
          {
             piKeyword->Release();
             piKeyword = NULL ;
          }   
          if ( SUCCEEDED(rc) )
          {
             rc = piToolChapter->AddKeyword("Suppliers","String",piKeyword);
             if ( SUCCEEDED(rc) )
             {
                // Suppliers keyword will be invisible in the 
                // catalog browser
                piKeyword->SetHidden(TRUE);  
                piKeyword->Release();
                piKeyword = NULL ;
             }
          }
       }
 ...

The "ToolType" string keyword  is created thanks to the AddKeyword method of the CATICatalogChapter interface applied to piToolChapter the pointer on the Tools chapter. 

Same thing for the "Suppliers" keyword. Notice that this keyword is hidden from a Catalog Browser, in applying the SetHidden method on piKeyword the CATICatalogKeyword interface pointer of the keyword.

Default valuation

The default value for the "Suppliers" keyword is set thanks to the SetDefaultValue method of the CATICatalogChapter interface pointer on the Tools chapter, piToolChapter

 ...
       if ( SUCCEEDED(rc) && (NULL != piToolChapter))
       {
          CATUnicodeString Value = "MySupplierA" ;
          rc = piToolChapter->SetDefaultValue("Suppliers",Value);
       }
 ...

For the "ToolType" keyword there is not default value. On each description of the Tools chapter, a value will be set thanks to the SetValue method on a CATICatalogDescription interface pointer. Notice that if a keyword has a default value, its value can be nevertheless changed on each description. 

Pointing an External Chapter

 ...
       if ( SUCCEEDED(rc) && (NULL !=piToolChapter) )
       {
          CATILinkableObject * piLinkOnChapter = NULL ;
          CATUnicodeString ChapterName = "Screws";
          CATUnicodeString DocumentName = "CAAScrew" ;
          rc = ::CAAFindChapterInCatalog(DocumentName,iOutputPath,ChapterName,IID_CATILinkableObject,
                                              (void**)&piLinkOnChapter);

          if ( SUCCEEDED(rc) )
          {
             CATICatalogDescription * piDescription = NULL ;
             rc = piToolChapter->AddDescription(piDescription,piLinkOnChapter);
             if ( SUCCEEDED(rc) && ( NULL != piDescription) )
             {
                rc = piDescription->SetValue("ToolType","Screws");

                piDescription->Release();
                piDescription = NULL ;
             } 
             piLinkOnChapter->Release();
             piLinkOnChapter = NULL ;                    
           }
       }
 ...

The CAAFindChapterInCatalog global function retrieves inside the CAAScrew.catalog, the Screws chapter. The output of this function is, in this case, the CATILinkableObject interface pointer on this external chapter. This pointer is the input of the AddDescription method applied to piToolChapter , the CATICatalogChapter interface pointer of the Tools chapter. It means that the piToolChapter chapter has a new description which contains a link towards the external Screws chapter. 

At last, the value of the "ToolType" keyword is set to "Screws" on the new description, piDescription, the description dedicated to the Screws chapter.

Creating a Chapter to Group Together the Part Families

 ...
       if ( SUCCEEDED(rc) )
       {
          CATUnicodeString ChapterName = "Nuts" ;
          CATBoolean IsEndChapter = FALSE ;

          rc = pICatalogChapterFactory->CreateChapter(ChapterName,IsEndChapter,piNutsChapter);
          ...
       }

 ...

The Nuts chapter is created thanks to the CATICatalogChapterFactory interface. The new chapter is linked with a parent chapter thanks a new description created on its parent chapter. In this case the parent chapter is the Tools Chapter. 

 ...
       if (SUCCEEDED(rc) && (NULL != piNutsChapter) && (NULL != piToolChapter) )
       {                  
          CATILinkableObject * pLinkOnChapter = NULL ;
          rc = piNutsChapter->QueryInterface(IID_CATILinkableObject,
                                              (void **) &pLinkOnChapter);     
          if ( SUCCEEDED(rc) )
          {
             CATICatalogDescription * piDescription = NULL ;
             rc = piToolChapter->AddDescription(piDescription,pLinkOnChapter);
             if ( SUCCEEDED(rc) && (NULL != piDescription) )
             {
                rc = piDescription->SetValue("ToolType","Nuts");

                piDescription->Release();
                piDescription = NULL ;
             }

             pLinkOnChapter->Release();
             pLinkOnChapter = NULL ;
          }
       }
...

Like any kind object to set in a description, the CATILinkableObject interface on the Nuts chapter, pLinkOnChapter, is necessary.  The AddDescription method applied  to the Tools chapter, the parent chapter pointed by piToolChapter, creates a new description with the pLinkOnChapter interface pointer on the Nuts chapter.

At last, the value of the "ToolType" keyword is set to "Nuts" on the new description, piDescription, the description dedicated to the Nuts chapter.

Creating  Keyword for the New Chapter

 ...
       if ( SUCCEEDED(rc) && (NULL != piNutsChapter) )
       {                  
          CATICatalogKeyword * piKeyword = NULL ;
          rc = piNutsChapter->AddKeyword("SideNumber","Integer",piKeyword);
          if ( SUCCEEDED(rc) )
          {
             piKeyword->Release();
             piKeyword = NULL ;
          }
       }
...

The integer "SideNumber" keyword is created on the Nuts chapter. piNutsChapter is the CATICatalogChapter interface pointer on the Nuts chapter.

Pointing an External Family

 ...
        if ( SUCCEEDED(rc) && (NULL != piNutsChapter))
        {
           CATILinkableObject * piLinkOnChapter = NULL ;
           CATUnicodeString ChapterName = "Nuts6SidesFamily";
           CATUnicodeString DocumentName = "CAANuts6Sides";
           rc = ::CAAFindChapterInCatalog(DocumentName,iOutputPath,
                                       ChapterName,IID_CATILinkableObject, 
                                           (void**) &piLinkOnChapter);
        
           if ( SUCCEEDED(rc) )
           {
              CATICatalogDescription * piDescription = NULL ;
              rc = piNutsChapter->AddDescription(piDescription,piLinkOnChapter);
              if ( SUCCEEDED(rc) && (NULL != piDescription) )
              {
                 ...
                 rc = piDescription->SetValue("SideNumber","6");
                 piDescription->Release();
                 piDescription = NULL ;
              }

              piLinkOnChapter->Release();
              piLinkOnChapter = NULL ;
           }
        }
...

The CAAFindChapterInCatalog global function retrieves inside the CAANuts6Sides.catalog, the Nuts6SidesFamily chapter. The output of this function is, in this case, the CATILinkableObject interface pointer on this chapter. This pointer is the input of the AddDescription method applied to piNutsChapter , the CATICatalogChapter interface pointer on the Nuts chapter. It means that the piNutsChapter chapter has a new description which contains a links towards the external Nuts6SidesFamily chapter.

At last, the value of the "SideNumber" keyword is set to "6" on the new description, piDescription, the description dedicated to the Nuts6SidesFamily chapter. 

Creating a Chapter to Group Together Sub-Chapters with Persistent Query

 ...
       CATICatalogChapter * piNutsWithFixedSizeHoleChapter = NULL ;

       if ( SUCCEEDED(rc) )
       { 
          CATUnicodeString ChapterName = "NutsWithFixedSizeHole" ;
          CATBoolean IsEndChapter = FALSE ;
          rc = pICatalogChapterFactory->CreateChapter(ChapterName,IsEndChapter,piNutsWithFixedSizeHoleChapter);
          ...
       }
       if ( SUCCEEDED(rc) && ( NULL != piToolChapter) )
       {
          CATILinkableObject * pLinkOnChapter = NULL ;
          rc = piNutsWithFixedSizeHoleChapter->QueryInterface(IID_CATILinkableObject,
                                              (void **) &pLinkOnChapter);     
          if ( SUCCEEDED(rc) )
          {
             CATICatalogDescription * piDescription = NULL ;
             rc = piToolChapter->AddDescription(piDescription,pLinkOnChapter);
             if ( SUCCEEDED(rc) && (NULL != piDescription) )
             {  
                // 2-6-3 Associating a value to the ToolType keyword
                rc = piDescription->SetValue("ToolType","Nuts");

                piDescription->Release();
                piDescription = NULL ;
             }

             pLinkOnChapter->Release();
             pLinkOnChapter = NULL ;
          }
       }
...

The same code as for the Nuts chapter. The  NutsWithFixedSizeHole chapter is created thanks to the CATICatalogChapterFactory interface.  The new chapter is linked with a parent chapter thanks a new description created on its parent chapter. In this case the parent chapter is the Tools Chapter. 

Like any kind object to set in a description, the CATILinkableObject interface on the NutsWithFixedSizeHole chapter, pLinkOnChapter, is necessary.  The AddDescription method applied  to the Tools chapter, the parent chapter pointed by piToolChapter, creates a new description with the pLinkOnChapter interface pointer on the NutsWithFixedSizeHole chapter.

At last, the value of the "ToolType" keyword is set to "Nuts" on the new description, piDescription, the description dedicated to the NutsWithFixedSizeHole chapter.

Closing the New Catalog

 ...
    if ( SUCCEEDED(rc) && (NULL != pDocument) )
    {
        CATUnicodeString DocumentName = "CAATool" ;
        rc = ::CAACloseCatalogDocument(DocumentName,*pDocument,iOutputPath);
        pDocument = NULL ;
    }
...

The CAACloseCatalogDocument global function saves the new catalog  under the name CAATool

Global Functions

In the CAACciCatalogServices.cpp you will find the global functions used in this use case, but also in the CAACciScrewCatalogCreation [1], the  CAACciNuts6SidesCatalogCreation [2] and the CAACciCatalogPersistentQuery [3] use cases.

[Top]


In Short

This use case illustrates how to create a catalog document in using the following interfaces:

[Top]


References

[1] Creating a Catalog With Part Documents
[2] Creating a Catalog With Part Family
[3] Creating Persistent Query
[4] Catalog Overview
[5] Building and Launching a CAA V5 Use Case
[6] Browsing a Catalog
[Top]

History

Version: 1 [Jul 2002] Document created
[Top]

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