The V-Suite CORE to PCF interface can be configured to execute a macro which assigns additional PCF Pipeline Header Attributes. The interface will execute the macro and write the result of the macro to the PCF pipeline header. The interface will assign the PIPELINE-REFERENCE as an input parameter to the macro. You can use this feature for example to lookup additional information related to the isometric drawing, such as revision number, drawing title, etc.


The PCF header macro is created via Macro Manager. In Macro Manager create a new macro. This will display the Macro Property Form;

Enter a name and macro type. The macro type must be PCF Header 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 PIPELINE-REFERENCE parameter to assign additional information to the PCF file which then can plotted on the isometric.

Consider the following example:

Suppose the PIPELINE-REFERENCE is a isometric drawing number and some external document management system maintains information about the drawing, like revision and drawing title. The macro will lookup this information, increment the revision number and 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 an example of how this can be accomplished.

//PCF Header Macro

// Get the parameter (set by the PCF Interface)

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

// MAIN BODY

// The Macro must return a table of PCF Attributes which will be written to PCF Header

var resultTable = Utilities.NewVariableTable()

 

try

{

// The Database has a Data Connection to the Document Management System

var dmsConnection = Database.GetDataConnection("DMS")

 

// Create a reader to read the external data

// Form the query based PIPELINE-REFERENCE parameter

var drawingQuery = "SELECT * FROM DrawingTable WHERE dwgno = '" + pipelineReference + "'"

var dmsReader = Utilities.NewDataReader(dmsConnection, drawingQuery)

 

if (dmsReader == null)

{

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

// will present this in export wizard user interface

Messages.ShowMessage("Error connecting to DMS. PCF does not contain Drawing Info.")

 

throw "ConnectionError"

}

 

// Excpecting 1 record.

 

if (dmsReader.RecordCount > 1)

{

Messages.ShowMessage("Multiple Drawing Numbers found in DMS.")

throw "MultipleRecordError"

}

else if (dmsReader.RecordCount == 0)

{

Messages.ShowMessage("Drawing Number not found in DMS.")

}

else

{

//Proceed to first (and only) record

dmsReader.MoveNext()

var dwgTitle = dmsReader.GetValue("dwg-title")

var dwgRev = dmsReader.GetValue("dwg-rev")

var newRev = dwgRev + 1

 

// Assign Title to ATTRIBUTE1

 

// Assign Revision to ATTRIBUTE2

resultTable.AddVariable("ATTRIBUTE1", dwgTitle)

resultTable.AddVariable("ATTRIBUTE2", newRev)

}

 

 

RESULT = resultTable

}

catch

{

RESULT = resultTable

}

 

Many variations are possible. Note that PCF header macro must always conform these rules:

  • The macro must alway return an object of type VariableTable
  • The variable names in the variable table must comply to PCF Suppored Header Attributes
  • The PCF Interface will always write the PCF Header, reqgardless of whether the macro succeeds or fails. If it fails, the extended attribute information will not be added to the PCF header
  • To alert the user of the PCF Interface that an error occured in the macro, you should send a Message. No other macro API or JScript errors will be presented to the user.
  • The PCF will convert variable values to strings per the systems languague setting.