Creating a Catalog in Batch Mode  

Creating a Catalog in Batch Mode
Creating a Catalog with a Part Family in Batch Mode

 

This task explains how to create a catalog in Batch mode.

A Keyword Name is automatically added if a chapter or a family is added with interactive commands. However, the Keyword Name is not added when you use the  Batch process.

 

Creating a Catalog in Batch Mode

You will need access to the files BatchCatalog.csv and Catalog.CATScript in the samples folder.
For more information, you can open the file BatchCatalog.csv with an editor like Microsoft Excel and the Catalog.CATScript with a text editor like WordPad.
 
  1. Start the Catalog Editor workbench by selecting Infrastructure  ->  Catalog Editor from the Start menu.

  2. Open the file BatchCatalog.csv with an editor like Microsoft Excel. It looks like this:

The file BatchCatalog.csv contains the information required to create a complete chapter referencing subchapters (CHAPTER is specified in cell 1A with its name FirstChapter in 1B). 

The first chapter displayed in the csv file is the root chapter (FirstChapter) and it references other chapters. Each entity description starts with the chapter type (either CHAPTER or SUBCHAPTER) and is separated from the other descriptions by the word END. Do not forget that the description and the referenced subchapter must have the same name (e.g. "SubChapter1;SubChapter1" as shown in the BatchCatalog.csv file above) otherwise, an error will be issued in the report file of the Batch.

The names of the catalog documents containing the referenced chapters must also be given (SubChapter1 and SubChapter2 in 4A and 5A). 

In this particular example, SubChapter1 references a terminal (i.e. "end") chapter (SubChapter3 with its name in 26A) which is empty.
These two families of entities are described in FirstChapter by a keyword NAME and identified by the names SubChapter1 and SubChapter2 (in cells 4A and 5A).

  1. An example of what one of the families could look like is given in the .csv file extract below:

For each chapter (family or not) you must create either a text file (with columns separated by a comma or a  semi-colon) or an Excel file (with cells separated by a comma or semi-colon) and save it in the .csv format.

Note the following:

  • The first cell is reserved for the declaration of the chapter type: CHAPTER for a chapter referencing subchapters or ENDCHAPTER  for a family referencing one or more entities
  • The second cell is reserved for the name of the chapter to be generated
  • If you do not wish to use the default icons supplied with the application to identify the chapter to be generated, you can reserve one of the cells to indicate your own icon to be referred to. This cell may be called, for instance, "MyIcon". For more information see Using Icons at the end of this task. Our example uses the default icons thus there is no ScrewIcon column in the above image
  • The mandatory items are Keywords to define the names of the keywords associated with the chapter and Types to define their unit (or their type for simple cases).
    The types allowed are Real, String, Integer, Boolean and the units: m, mm or km for a LENGTH, etc. For more information see "About Parameters" in the Version 5 - Knowledge Advisor User's Guide
  • After Keywords and Types, each line represents a description of the constituent entities i.e. their keyword values, their name, their location and their associated external preview. The values attributed to the magnitudes are assumed to be in the unit (mm for LENGTH, g for MASS, etc). For more information see "About Parameters"  in the Version 5 - Knowledge Advisor User's Guide
  • The first column can be empty or can contain the name you want to associate to the description
  • The V5 document names in the column located after the last keyword of the description line (in our example, the CATPart documents in last column of BatchCatalog.csv) can be preceded by their location (with the complete path), otherwise an attempt is made to find these documents based on the link resolution strategy. See Linked Document Localization in the Infrastructure guide for more information
  • In the last column (and for families only), you can specify the external preview file you want to link to the component. This column is optional.
If, in the first column, you add a name that will be associated to the description then it must be different than the name of the chapter, e.g in the above example, the name should be different than "SubChapter3".
Do not use the quote symbol (") in any cell (chapter name, keyword name, keyword value) to enable queries on your chapter. In the query syntax, this symbol is used exclusively to isolate keywords whose names may contain non-alphanumeric characters.
Example: "DESIGNATION :"=="CHC" 
Make sure when entering paths and filenames in the .csv file that upper and lowercase characters are kept as is.
  1. On Windows:
    Open an empty Excel file and, with the aid of the BatchCatalog.csv file supplied, complete the table giving all the keywords, types and catalog names required for the creation of the chapter.

  2. Once you have completed the Excel file save it in the csv format making sure it is comma or semi-colon delimited.

On UNIX:
The csv format is a text format recognized by UNIX. Any Excel file opened on Windows and saved in the csv format can subsequently be used on UNIX.
However, if you prefer to work exclusively on UNIX you can use any text editor provided you use the same syntax as the csv format i.e. cell separation by comma or semi-colon.

In case the catalog you create contains a family described by a CATPart with a design table, bear in mind that the CATPart will not be resolved. Resolving a CATPart with a design table requires another CATScript file detailed in Creating a Catalog with a Part Family in Batch Mode.

  1. Before being able to use the CATScript file in order to run the Batch operation you must make sure the CclTypeLib library is loaded. This library declares the catalog creation method. To do this, select the Tools -> Options... command. The Options dialog box appears with the General category selected in the left-hand column.

  2. Click the Macros tab. The following dialog box appears:

  3. Click the All references... button. This displays the Current references dialog box containing a list of all the Version 5 TypeLibs because they are installed automatically.

  4. Check that the CclTypeLib library is displayed in the list:

  5. If the CclTypeLib library is not in the list click on the Add file... button and retrieve the library from intel_a\code\bin. Make sure it is in the Selected list before clicking OK.

  6. Open the file Catalog.CATScript with a text editor like WordPad. In our example, the content looks like this (comments are written in green):

 

Language="VBSCRIPT"

Sub CATMain()

InputFile ="E:\users\Catalogs\BatchCatalog.csv"
(Defines the absolute path of the input csv or text file)

OutputFile ="E:\users\Catalogs\Catalog_Result.catalog"
(Defines the absolute path of the input csv or text file)

Dim Catalog As Document
Set Catalog=CATIA.Documents.Add("CatalogDocument")

(Creates a document of type CatalogDocument)

Catalog.CreateCatalogFromcsv InputFile, OutputFile
(Calls the CreateCatalogFromcsv method on Catalog to create the catalog)

Catalog.Close
(Closes the document)

End Sub

 

As you can see, this file, written in the VBScript language, contains the information required to Batch-generate a .catalog file in the location you specify. It can be used on both Windows and UNIX.

  1. If you want to use it, copy it and change the csv file and catalog file paths to adapt them to your environment. The comments relating to these paths are shown above in light green.

A CATScript file can include multiple sets of instructions for the generation of multiple  catalogs.

  1. You are now ready to run the Batch operation. Select the Tools ->Macro->Macros command. The following dialog box appears:

  2. Click the Select... button then navigate in the Select a macro file dialog box to choose the appropriate CATScript file. Click the Run button which is now grayed out.

    This Batch operation will generate:

    • a report named Catalog_Result.report in the same location as the catalog file, allowing you to check successful creation of the catalog. For example:

 

 

The above example shows only an extract but the .report file details each description, ending with the catalog creation status.

  • and a catalog named Catalog_Result.catalog, containing subchapters with the name originally given in the Excel file.
You are advised to keep the .csv files used for catalog generation as no changes can be made to the catalog without completely regenerating it in the way described above.
  1. To open the catalog, see Browsing a Catalog.

Using Icons

If you prefer not to use the default icons supplied with the catalog application, you can associate one of your own with each chapter. You can do that by putting:

  • either the complete path indicating the location of the icon
  • or just the name of the icon (without the .bmp extension)

in the cell reserved for referring to your own icons.

If for whatever reason the icon you wish to use is not found no icon will appear, neither the default icon nor of course the icon you wanted to associate yourself.

Entering the complete path has the disadvantage of presenting problems when exporting the catalog to another site.

Entering just the name means that you must put all your icons in a single folder or directory which you must create (and not in the Version 5 file tree). You must then concatenate the folder/directory location by resetting the Version 5 environment variable "CATGraphicPath" in your current environment to point to the folder/directory. When exporting the catalog, you then only have to reset the variable specifying the receiving site.

For more information about customizing environments, see Managing Environments in CATIA Installation & Administration User's Guide.

 

Creating a Catalog with a Part Family in Batch Mode  

This task explains how to create a catalog containing parts with a design table in Batch mode.

This creation mode lets you add only one design table to your catalog.

Bear in mind that:

  • the design table must contain a column entitled "PartNumber": each description is associated to a row in the design table using the "PartNumber" keyword
  • you cannot add a part family if the generative part referenced by the design table is already opened in an editor
  • Excel files are not supported on UNIX. As a consequence, if your design table is in .xls format, you need to convert it to the .txt format to be able to use it. You must then reroute the link of the .CATPart document from the former .xls design table to the new .txt design table: to do so, select the Edit->Links... command then use the Replace button.
Have access to the CatalogResolveDescription.CATScript and PartWithDT.CATPart located in the samples folder.
  If you want to indicate precisely whether a description should be resolved or not, edit the design table by adding the keyword "CATCatalog_ResolveDescription" then specifying the boolean value "TRUE" (or "T") or "FALSE" (or "F") next to each description.
To illustrate this, let's have a look at the example below in which the descriptions n° 1, 3 and 5 will be resolved:
  PartNumber PartBody\Pad.1\FirstLimit\Length (mm) CATCatalog_ResolveDescription
1 20 TRUE
2 40 FALSE
3 60 TRUE
4 80 FALSE
5 100 TRUE
  Note that when the keyword "CATCatalog_ResolveDescription" has been added to the design table, using the Add Part Family command in the Catalog Editor will resolve the descriptions indicated as "TRUE" (or "T").
Before being able to use the CATScript file in order to run the Batch operation you must make sure the CclTypeLib library is loaded. To do this, repeat the above-mentioned steps 6 to 10 in "Creating a Catalog in Batch Mode".
  1. Open the file CatalogResolveDescription.CATScript. It looks like this (comments are written in black):

 

Language="VBSCRIPT"

Sub CATMain()
ChapterName ="NewChapter"
(Defines the name of the new part family)

InputFile ="E:\users\Catalogs\PartWithDT.CATPart"
(Defines the absolute path of the CATPart file)

Dim Catalog As Document
Set Catalog=CATIA.Documents.Add("CatalogDocument")

(Creates a document of type CatalogDocument)

Catalog.CreateChapterFromDesignTable ChapterName, InputFile
(Calls the CreateChapterFromDesignTable method on Catalog to create the part family)

Catalog.SaveAs ("E:\users\Catalogs\ResolvedDescription_Result.catalog")
(Saves the document under the specified name in the specified location)

Catalog.Close
(Closes the document)

End Sub

  1. If you want to use it, copy it and change the ChapterName and the InputFile name and path to adapt them to your environment. 

     

    In the example above the CATScript file contains just one set of instructions for the Batch-generation of one part family. However, a CATScript file can of course include several series of instructions for the generation of several families.
  1. Select the Tools ->Macro->Macros command. The following dialog box appears:

  2. Click the Select... button then navigate in the Select a macro file dialog box to choose the appropriate CATScript file. Click the Run button which is now grayed out.

This Batch operation will generate:

  • a catalog named ResolvedDescription_Result.catalog (according to the name originally given in the Excel file)
  • a new chapter containing the part and its associated design table
  • and the .CATPart documents referred to by the part family. These documents are saved in the folder you specified in the Folder field under the Tools -> Options -> Infrastructure -> Catalog Editor tab.