The V-Suite CORE to PCF interface can be configured to execute a macro that assigns additional PCF Component Attributes. The interface will execute the macro and write the results to the PCF component. The interface assigns several input parameter to the macro. You can use this feature to, for instance, lookup additional information related to the component such as material, item code, and so on.

The PCF component macro is created via Macro Manager, Creating a new macro will display the macro property form;

Specify the macro name and type. The type must be PCF Component Macro. A system macro of this type cannot be executed by a user and will have a predefined set of parameters set by the PCF interface. You will be able to view the parameters but will not be able to modify. Click the Parameters tab to view the parameters.

The purpose of the macro is to use the input parameters to assign additional information to each component in the PCF file.

For instance, suppose you have a specification database which identifies material description and item code (material code). The following macro will look up this information based on specification and other paramaters to assign the material information will return this information to the interface so that it is exported to the PCF file. Please note that the macro may only return values that are supported by PCF. Refer to the topic about PCF Attributes for information about PCF supported attributes. The following JScript expression is a snippit of an example of how this can be accomplished.

 

//PCF Component Macro

var pipelineReference = PARAMETERS.Get("PIPELINE-REFERENCE")

var symbolKey = PARAMETERS.Get("SKEY")

var componentIdentifier = PARAMETERS.Get("COMPONENT-IDENTIFIER")

var npd1 = PARAMETERS.Get("NOMINAL-DIAMETER1")

var npd2 = PARAMETERS.Get("NOMINAL-DIAMETER2")

var rating = PARAMETERS.Get("RATING")

var schedule = PARAMETERS.Get("SCHEDULE")

var instTag = PARAMETERS.Get("INSTRUMENT-TAG")

var insulationSpec = PARAMETERS.Get("INSULATION-SPEC")

var paintingSpec = PARAMETERS.Get("PAINTING-SPEC")

var materialSpec = PARAMETERS.Get("PIPING-SPEC")

var tracingSpec = PARAMETERS.Get("TRACING-SPEC")

var compAtt1 = PARAMETERS.Get("COMPONENT-ATTRIBUTE1")

var compAtt2 = PARAMETERS.Get("COMPONENT-ATTRIBUTE2")

var compAtt3 = PARAMETERS.Get("COMPONENT-ATTRIBUTE3")

var compAtt4 = PARAMETERS.Get("COMPONENT-ATTRIBUTE4")

var compAtt5 = PARAMETERS.Get("COMPONENT-ATTRIBUTE5")

var compAtt6 = PARAMETERS.Get("COMPONENT-ATTRIBUTE6")

var compAtt7 = PARAMETERS.Get("COMPONENT-ATTRIBUTE7")

var compAtt8 = PARAMETERS.Get("COMPONENT-ATTRIBUTE8")

var compAtt9 = PARAMETERS.Get("COMPONENT-ATTRIBUTE9")

var compAtt10 = PARAMETERS.Get("COMPONENT-ATTRIBUTE10")

try

{

// The Database has a Data Connection to the SPEC Database

var specConnection = Database.GetDataConnection("SPEC")

 

// Create a reader to read the external data

// Form the query based PIPING-SPEC parameter and other parameters like Symbol Key

 

string query = SELECT * FROM SpecTable WHERE SKEY = '" + symbolKey + "'"

query += " AND SPEC = '" + materialSpec + "'"

 

if (componentIdentifier == "FLANGE")

{

query += " AND NPD1 = " + npd1

query += " AND RATING = '" + rating + "'"

}

else if (componentIdentifier == "PIPE")

{

query += " AND NPD1 = " + npd1

query += " AND SCHEDULE = '" + schedule + "'"

}

else if (componentIdentifier == "REDUCER-CONCENTRIC")

{

query += " AND NPD1 = " + npd1

query += " AND NPD2 = " + npd2

query += " AND SCHEDULE = '" + schedule + "'"

}

else if { ... ETC}

 

var specReader = Utilities.NewDataReader(specConnection, specQuery)

 

if (specReader == null)

{

// The PCF Interface will receive messages from the macro and

// will present this in export wizard user interface

Messages.ShowMessage("Error connecting to SPEC. PCF Component does not contain Material Info.")

 

throw "ConnectionError"

}

 

// Excpecting 1 record.

 

if (specReader.RecordCount > 1)

{

Messages.ShowMessage("Multiple Item Codes found in SPEC.")

throw "MultipleRecordError"

}

else if (specReader.RecordCount == 0)

{

Messages.ShowMessage("Itemcode not found in SPEC.")

throw "RecordNotError"

}

else

{

//Proceed to first (and only) record

specReader.MoveNext()

var itemCode = specReader.GetValue("STOCKCODE")

var itemDesc = specReader.GetValue("MAT-DESC")

// Assign variables

resultTable.AddVariable("ITEM-CODE", itemCode)

resultTable.AddVariable("ITEM-DESCRIPTION", itemDesc)

}

 

 

RESULT = resultTable

}

catch

{

RESULT = resultTable

}

 

There are many variations possible. PCF component macros must comply with these rules:

  • The macro must return an object of type VariableTable
  • Variable names in the VariableTable must comply to PCF Supported Component Attributes
  • The PCF Interface will always write the PCF component information, regardless of whether the macro succeeds or fails. If it fails, the extended attribute information will not be added to the PCF component
  • To alert users of errors, you must send a Message. No other macro API or JScript errors will be presented to users.
  • The PCF will convert variable values to strings per the systems languague setting.