HowTo: Find the Item List for a Given Model

Version: 16.2

Table of Contents

Preface

Discusses how to find a list of items for a given model.

Background

Project Control Files (PCFs) and Model files are inter-related in so far as the items defined within the Model file are all listed within the PCF. The PCF generally provides all the information necessary to work on the data files for a given project.

Finding the Item List for a Given Model

By using the Pcf object's itemlist() function one is able to get a list of items that are defined for a model. As an example consider that you have Project Control File (PCF) called samp10.dat, and a model file called samp15.dat. You can determine the item list with the following script,

from grail.data import pcf
p = pcf.Pcf("samp10.dat")
itemlist = p.itemlist("samp15.dat")

which returns a list of items that are found in the samp15.dat model file that is part of the samp project.

Item Lists within Compass Style Scripts

When you are within a compass style script (a script that requires you define a project file to start), then you can retrieve the contents of the item list using the grail.compass.cmpsys module's getpcf() function. For example, the following line will retrieve the current Pcf object, and determine the items for a File 13 model file,

p = cmpsys.getpcf()
items = p.itemlist("samp13.dat")