Integration with Other Applications > Windchill Workgroup Manager Documentation > ECAD > Advanced Techniques > Using Hooks > Hook Usage
  
Hook Usage
This section describes each of the various hooks and the variables that they use to pass data. Following each description is an example of a Windows batch file that provides an appropriate function for that hook.
Pre Update Hook
The Windchill Workgroup Manager contains no related default built-in action analogous to the pre-update hook. It is used only to launch an external script. Scripts associated with the pre-update hook will be launched before invoking any actions from the ECAD Update or Import functions.
No input and no output files are needed for this hook.
An example of the use of the "Pre Update" hook is to automate running some ECAD utilities or customization executable that affect primary and derived ECAD Design Data.
DESIGN_DIR
Represents the directory for the design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Example:
@echo off
echo Starting Pre Update Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo BUILT IN IS INCORRECT FLOW IN THIS PREUPDATE ACTION
GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Doing Something
GOTO ONEXIT

:ONEXIT
echo Pre Update Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Pre Update Hook execution.
exit /B 1
Create Viewable Hook
The program assigned to this hook must create a viewable file based on the design item. The target directory and the required name for the viewable file are passed to the hook by HOOK_OUTPUT environment variable. The location and the name of viewable file are specified by the HOOK_OUTPUT environment variable.
Input
DESIGN_DIR
Represents the directory for the design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
Output
HOOK_OUTPUT
Represents the full path to the eda file which must be created.(The target directory and the required file name.) For example, …/[Viewable]/[HookResult]/< viewable name + extension >
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Example:
@echo off
echo Starting Generate Viewable Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------
echo HOOK_TEMP = %HOOK_TEMP%
echo HOOK_LOG = %HOOK_LOG%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT

copy /Y %HOOK_INPUT% %HOOK_OUTPUT%

GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Viewable file will be generated by hook only

REM Run some utility that generates viewable
set ADDFILENAME=GenerateViewable__SKIPBuiltInExecutionResult
echo %ADDFILENAME%>>%HOOK_OUTPUT%

GOTO ONEXIT

:ONEXIT
echo Generate Viewable Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Generate Viewable Hook execution.
exit /B 1
Create BOM Hook
The program assigned to this hook must create or modify a generic BOM file. The hook result will be stored in the directory specified by the HOOK_OUTPUT environment variable.
The target Generic CSV file name for Generic BOM is constant and equals to “Design.csv”.
The Create Generic BOM Process is:
Create a generic CSV file.
Convert the generic CSV file to the Windchill Workgroup Manager’s internal representation.
Attach it to the Windchill document.
The hook may:
Case1: Create a new generic CSV file by itself or
Case2: Modify the Generic CSV file that was created by the built-in implementation.
Input
DESIGN_DIR
Represents the directory for design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
HOOK_INPUT
Represent the full path to the Generic CSV file created by Built-In implementation and equal to
Case 1) NULL
Case 2) The full path to the CSV file created by Built-In.
Output
HOOK_OUTPUT
Represents the full path to the target Generic CSV file.
(The target directory + the required file name.)
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[GenericBOM]/[BuiltInResult]/Design.csv
HOOK_OUTPUT
…/[GenericBOM]/[HookResult]/Design.csv
Example:
@echo off
echo Starting Generate Primary BOM Hook executing execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------
echo HOOK_TEMP = %HOOK_TEMP%
echo HOOK_LOG = %HOOK_LOG%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of built in action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT

copy /Y %HOOK_INPUT% %HOOK_OUTPUT%

GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Generic CSV file will be created by hook only

REM Run some utility that generates generic BOM
set ADDFILENAME=GeneratePrimaryBOM__SKIPBuiltInExecutionResult
echo %ADDFILENAME%>>%HOOK_OUTPUT%

GOTO ONEXIT

:ONEXIT
echo Generate Primary BOM Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Generate Primary BOM Hook executing execution.
exit /B 1
Create Variant BOMs Hook
The program assigned to this hook must create or modify a variant BOM files. The hook result will be stored in the directory specified by the HOOK_OUTPUT environment variable.
The Create Variant BOM Process is:
Create the variant CSV files.
The Windchill Workgroup Manager converts these CSV files to its internal representation.
Attach these files to the Windchill document.
The hook may:
Case 1) Create variant CSV files or
Case 2) Modify variant CSV files that were created by the Built-In implementation.
Input
DESIGN_DIR
Represents the directory for design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
HOOK_INPUT
Represents the path to the directory where the Built-In impl creates Variant CSV files.
Case 1) Is equal to NULL
Case 2) Full path to directory where the Built-In impl. placed its Variant CSV files.
Output
HOOK_OUTPUT
Represents the path of the target directory where the hook must:
Case 1) Created CSV files
Case 2) Place modified CSV files.
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
The file name for each variant CSV file is variant_name dot CSV.
HOOK_INPUT
…/[VariantBOM]/[BuiltInResult]
HOOK_OUTPUT
…/[VariantBOM]/[HookResult]
Example:
@echo off
echo Starting Generate Variant BOM Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT
copy /Y %HOOK_INPUT% %HOOK_OUTPUT%
set ADDFILENAME=GenerateVariantBOM__USEBuiltInExecutionResult
echo %ADDFILENAME%>>%HOOK_OUTPUT%
GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Variant CSV files will be created by hook only
REM Run some utility that generates Variants BOM
set ADDFILENAME=GenerateVariantBOM__SKIPBuiltInExecutionResult
echo %ADDFILENAME%>>%HOOK_OUTPUT%
GOTO ONEXIT

:ONEXIT
echo Generate Variant BOM Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Generate Variant BOM Hook execution.
exit /B 1
Create List of Design Files Hook
A “Design File List” is a list of paths for all files that are considered as part of the design data. Each line in the output file represents an individual path. Each path may begin with $DESIGN_DIR macro, which will be expanded to the design directory location.
* 
Design files are zipped files containing primary design data.
The hook may:
Case 1) Create a new Design File List or
Case 2) Update the Design File List created by the Built-In implementation.
The “Design File List” output file must be created in the target directory and has the required file name. The full path to the output file is specified by the HOOK_OUPUT environment variable.
If no files are listed in the hook output file, the Create Design Zip action will fail.
DESIGN_DIR
Represents the directory for the design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
HOOK_INPUT
Represents the full path to a file which contains the List of the design files created by the Built-In impl and equal to:
Case 1) Null
Case 2) Path to the list created by Built-In implementation.
Output
HOOK_OUTPUT
Represents the full path of the target file where the Design File list must be created.
Case 1) Hook creates this list.
Case 2) The external program modifies the list created by Built-In implementation
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[DesignFileList]/DesignFileList_BuiltInResult.txt
HOOK_OUTPUT
…/[DesignFileList]/DesignFileList_HookResult.txt
Example:
@echo off
echo Starting Get Design File List Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
REM In addition to Built-In action, run some utility that modifies design files list
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT
copy /Y %HOOK_INPUT% %HOOK_OUTPUT%
GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Add your path to HOOK_OUTPUT
REM Run some utility that calculates design files list
echo %HOOK_OUTPUT%>%HOOK_OUTPUT%
GOTO ONEXIT

:ONEXIT
echo Get Design File List Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Get Design File List Hook execution.
exit /B 1
Create List of Attachments Hook
The program assigned to this hook must create a list of all files that will be attached to the updated document. Requirements to the Attach Content List are:
Files must be listed on separate lines.
Paths may begin with the $DESIGN_DIR macro which will be expanded to the design directory location.
The Hook may:
Case 1) Create the new attachment file list or
Case 2) modify the attachment file list that was created by the Built-In implementation.
The target attachment file list must be written in the output file which is designated by the HOOK_OUTPUT environment variable.
If “skip_default_action” parameter is false in the hook definition, the Windchill Workgroup Manager client will update the attachment file list and write this list to an input text file.
The path to the input file is stored in HOOK_INPUT environment variable.
Input
DESIGN_DIR
Represents the directory for the design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
HOOK_INPUT
Represents the full path to the input file where the Built-In impl writes its “Attachment File List” and equal to
Case 1) NULL
Case 2) The path to the input file created by the Built-In impl.
Output
HOOK_OUTPUT
Represents the full path to the output file where the hook writes:
Case 1) Created list.
Case 2) Modified “Attachment File List”.
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[AttachmentFileList]/AttachmentFileList_BuiltInResult.txt
HOOK_OUTPUT
…/[AttachmentFileList]/AttachmentFileList_HookResult.txt
Examples:
@echo off
echo Starting Get Attachment File List Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
REM In addition to Built-In action, run some utility that modifies attachment file list
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT
copy /Y %HOOK_INPUT% %HOOK_OUTPUT%
echo SECONDARY,INFORMATION,%HOOK_INPUT%>>%HOOK_OUTPUT%
echo SECONDARY,INFORMATION,%HOOK_OUTPUT%>>%HOOK_OUTPUT%
GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Created Attachment File List by hook only
REM Run some utility that calculates attachment file list
echo SECONDARY,INFORMATION,%HOOK_OUTPUT%>>%HOOK_OUTPUT%
GOTO ONEXIT

:ONEXIT
echo Get Attachment File List Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Get Attachment File List Hook execution.
exit /B 1
Retrieve Attributes from Design Hook
The program assigned to this hook must create name-value pairs for attributes that must be published to the updated EPM document when the Save to WS action is performed. These name-value pairs must be written to the file designated by the HOOK_OUTPUT environment variable. This functionality is specific for hook only. Windchill Workgroup Manager for ECAD doesn’t have Built-In implementation.
Each name-value pair must be listed on separate line. When parsing such line, substring to the left of the first = character is considered name of the attribute, substring to the right of the first = character is interpreted as value. Leading and trailing white space character are removed from both name and value. String values consisting of multiple lines are not supported.
Input
DESIGN_DIR
Represents the directory for the design data.
DESIGN_ITEM
Represents the Design item selected for this update operation
HOOK_INPUT
Represents the full path to the input file that contains the IBAs and their values that currently are part of the EPMDocument and equal to
Case 1) NULL
Case 2) The path to the input file created by prepare hook action.
Output
HOOK_OUTPUT
Represents the full path to the output file where the hook creates “Design Attributes”
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[GetDesignAttributes]/GetDesignAttributes_BuiltInResult.txt
HOOK_OUTPUT
…/[GetDesignAttributes]/GetDesignAttributes_HookResult.txt
Example:
@echo off
echo Starting Get Design Attributes Value Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------

REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
REM In addition to Built-In action, run some utility that retrieves additional attributes from design data
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT
copy /Y %HOOK_INPUT% %HOOK_OUTPUT%
echo ECAD_DEMO_COLOR=GetDesignAttributes__USEBuiltInExecutionResult>>%HOOK_OUTPUT%

GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Added attributes by hook only
REM Run some utility that retrieves attributes from design data
echo ECAD_DESIGN_ITEM=%DESIGN_ITEM%>%HOOK_OUTPUT%
echo ECAD_NEUTRAL_FORMAT_FILE=%NEUTRAL_FORMAT_FILE%>>%HOOK_OUTPUT%
echo ECAD_DEMO_COLOR=GetDesignAttributes__SKIPBuiltInExecutionResult>>%HOOK_OUTPUT%
GOTO ONEXIT

:ONEXIT
echo Get Design Attributes Value Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Get Design Attributes Value Hook execution.
exit /B 1
Get Design Directory Hook
Some tools keep board related files in a subdirectory inside a schematic directory. For these tools it is usually possible to find out the name of this board related subdirectory.
The program assigned to this hook must:
Receive ECAD Project directory.
Return the valid board design subdirectory inside the ECAD schematic directory.
For another tools hook returns the received directory.
If Get Design Dir returns NULL, then the project directory will be considered as invalid.
DESIGN_DIR
Represents the directory for the design data.
HOOK_OUTPUT
Represents the path to the output file. The hook writes in this file the valid board design subdirectory.
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
The path to valid board design subdirectory will be written to HOOK_OUTPUT environment variable by hook.
Suggested value
HOOK_OUTPUT
…/OS_Temp/[ECAD_UWGM]/[DesignDir]/DesignDir_HookResult.txt
Example:
@echo off
echo Starting Get Design Dir Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------
echo HOOK_TEMP = %HOOK_TEMP%
echo HOOK_LOG = %HOOK_LOG%
echo -------------------------------------------------------------------------------


REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
REM In addition to Built-In action, run some utility that calculates design dir
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT

copy /Y %HOOK_INPUT% %HOOK_OUTPUT%

GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Get design dir by hook only
REM Run some utility that calculates design dir

echo %DESIGN_DIR%>%HOOK_OUTPUT%

GOTO ONEXIT

:ONEXIT
echo Get Design Dir Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Get Design Dir Hook execution.
exit /B 1
Get Design Item List Hook
The Design Item List is a list of files which are considered to be design items. Those files are located in the given valid directory. This list is separated list of names for these files.
The hook can:
Case 1) Create a new design item list, or
Case 2) Modify the design item list that was created by the built-in implementation.
The Built-In implementation creates the design item list as a simple listing of all files having a special extension in the given directory, or, in case 2, the hook receives a valid design directory from the input file and modifies the design item list that was created by the built-in implementation. The modified list will be written to the output file.
The full path to the file which contains the input list is designed by the HOOK_INPUT environment variable.
The full path to the file which contains the output list is designed by the HOOK_OUTPUT environment variable.
DESIGN_DIR
Represents the directory for the design data.
HOOK_INPUT
Represents the full path to the input file which contains the Design Items List created by Built-In impl and equal to:
Case 1) NULL
Case 2) Path to input file created by built-in implementation.
Output
HOOK_OUTPUT
Represents the full path to the output file which contains the Design Items List created or modified by hook.
Case 1) Path to output file that contains Design Item List created by hook.
Case 2) Path to output file that contains Design Item List modified by hook.
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[DesignItemList]/DesignItemList_BuiltInResult.txt
HOOK_OUTPUT
…/[DesignItemList]/DesignItemList_HookResult_List.txt
Example:
@echo off
echo Starting Get Design Item List Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------
echo HOOK_TEMP = %HOOK_TEMP%
echo HOOK_LOG = %HOOK_LOG%
echo -------------------------------------------------------------------------------


REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
REM In addition to Built-In action, run some utility that modifies design item list
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT

copy /Y %HOOK_INPUT% %HOOK_OUTPUT%
echo "Design Item 1, which was added by hook">>%HOOK_OUTPUT%
echo "Design Item 2, which was added by hook">>%HOOK_OUTPUT%

GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Design Item List will be created by hook only

echo "Design Item 1, which was added by hook">>%HOOK_OUTPUT%
echo "Design Item 2, which was added by hook">>%HOOK_OUTPUT%

GOTO ONEXIT

:ONEXIT
echo Get Design Item List Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Get Design Item List Hook execution.
exit /B 1
Get List of Neutral Format Items Hook
A Neutral Format Item List is a list of neutral format files which are located in the given valid design directory. This list is built as a separated list of neutral format file names. Some ECAD tools use neutral format files which are not supported by Windchill. All such tools are declared as neutral format dependent tool. For these tools we expect to find the neutral format files in the design directory. If not, the design data is considered to be invalid.
The program assigned to this hook must return the “Neutral Format Item List” for the given valid directory.
The hook can:
Case 1) Create the new “Neutral Format Item List” or.
Case 2) Modify the “Neutral Format Item List” which was created by the Built-In impl.
The Built-In implementation creates a“Neutral Format Item List” as a simple listing of all files having a special extension in the given directory. (Neutral files)
The hook receives a valid design directory and this created list from the input file. The Updated by hook list will be written in output file.
The path to this input file is designed by the HOOK_INPUT environment variable.
The path to this output list is designed by the HOOK_OUTPUT environment variable.
DESIGN_DIR
Represents the directory for design data.
HOOK_INPUT
Represents the full path to the input file which was filled by the Built-In impl.
Case 1) NULL
Case 2) Full path to input file which contains the list created by Built-In impl.
Output
HOOK_OUTPUT
Represents the full path to the output file. This file contains the Neutral Format Item List created or modified by the hook.
Case 1) Created by hook
Case 2) Modified by hook
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[NeutralFormatItemList] /NeutralFormatItemList_BuiltInReslut.txt
HOOK_OUTPUT
…/[NeutralFormatItemList] /NeutralFormatItemList_HookResult.txt
Example
@echo off
echo Starting Get Neutral Formal Item List Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------
echo HOOK_TEMP = %HOOK_TEMP%
echo HOOK_LOG = %HOOK_LOG%
echo -------------------------------------------------------------------------------


REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result
REM In addition to Built-In action, run some utility that modifies neutral formal item list
echo USE BUILT IN: Copy HOOK_INPUT to HOOK_OUTPUT
copy /Y %HOOK_INPUT% %HOOK_OUTPUT%

echo "Neutral Format Item 1, which was added by hook">>%HOOK_OUTPUT%
echo "Neutral Format Item 2, which was added by hook">>%HOOK_OUTPUT%
GOTO ONEXIT

:SKIP_BuiltIn
echo SKIP BUILT IN: Add your path to HOOK_OUTPUT
REM Run some utility that calculates neutral formal item list
echo "Neutral Format Item 1, which was added by hook">>%HOOK_OUTPUT%
echo "Neutral Format Item 2, which was added by hook">>%HOOK_OUTPUT%

GOTO ONEXIT

:ONEXIT
echo Get Neutral Formal Item List Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred during Get Neutral Formal Item List Hook execution.
exit /B 1
Validate Design Hook
The Validate Design action checks if the given design directory is valid. The validation may be done either by the built-in implementation or by the external program. Neutral format dependent tools must be checked if design directory contains neutral format files for related design items.
This hook may:
Case 1) Validate the given design data by itself. (Replace the Built-In implementation.)
Case 2) Continue with more sophisticated Validation of the design data if the Validation of Built-In implementation returns “Design is valid”
DESIGN_DIR
Represents the directory for the design data.
HOOK_INPUT
Represents the full path to input file where the Built-In impl writes its validation result. This environment variable may be equal to:
Case 1) NULL
Case 2) Path to the input file, which contains the validation result determined by the built-in implementation.
HOOK_OUTPUT
Represents the full path to output file where hook writes the result of the design validation.
Execution result
By returned value
Errors
STDERR
* 
STDERR writes its output to a log file called HookLog.log.txt. Look here for debugging information.
Suggested values
HOOK_INPUT
…/[OS_Temp]/…/[ValidateDesign]/ValidateDesign_BuiltInResult.txt
HOOK_OUTPUT
…/[OS_Temp]/…/[ValidateDesign]/ValidateDesign_HookResult.txt
Example:
@echo off
echo Starting Validate Design hook Hook execution

REM Print values of base hook parameters and environment variables
echo -------------------------------------------------------------------------------
echo DESIGN_DIR = %DESIGN_DIR%
echo DESIGN_ITEM = %DESIGN_ITEM%
echo NEUTRAL_FORMAT_FILE = %NEUTRAL_FORMAT_FILE%
echo BUILT_IN_EXECUTION = %BUILT_IN_EXECUTION%
echo HOOK_INPUT = %HOOK_INPUT%
echo HOOK_OUTPUT = %HOOK_OUTPUT%
echo -------------------------------------------------------------------------------
echo HOOK_TEMP = %HOOK_TEMP%
echo HOOK_LOG = %HOOK_LOG%
echo -------------------------------------------------------------------------------


REM Select a case of the hook: use or skip result of Built-In action
if Not DEFINED BUILT_IN_EXECUTION GOTO ON_ERROR_EXIT

if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:False GOTO SKIP_BuiltIn
if %BUILT_IN_EXECUTION%==BuiltInExecutionResult:True GOTO USE_BuiltIn

GOTO ON_ERROR_EXIT

:USE_BuiltIn
echo USE BUILT IN: Hook will update Built-In result

copy /Y %HOOK_INPUT% %HOOK_OUTPUT%

GOTO ONEXIT

:SKIP_BuiltIn
echo Validate by hook only
REM Execute some utility that checks the validity of the design
REM set ADDFILENAME="ValidateDesign:False"
set ADDFILENAME=ValidateDesign:True
echo %ADDFILENAME%>%HOOK_OUTPUT%
echo Hook reslt is : %ADDFILENAME%
GOTO ONEXIT

:ONEXIT
echo Validate Design hook Hook finished successfully.
exit /B 0

:ON_ERROR_EXIT
echo Error occurred duriung Validate Design hook Hook execution.
exit /B 1