Recalculating all blocks

The Hull Clone utility can run child processes through the system command, as well as CADMATIC Hull executables. Hence a JavaScript can be written to recalculate all construction in a project and/or reference surfaces.

Below is an example of a script that recalculates all the blocks in a COS (distributed) project, including the reference surfaces.

Introduction

The example script makes use of the Hull COS Client Command Line Interface (HCC CLI) to query the COS state of the blocks in the project, and to execute the relevant COS commands. These commands need to know the Hullcentre path and the project path. Both paths can be passed either through an environment variable or as a command line parameter. In this example both techniques are displayed.

  • The project path is passed as command line parameter in the script.

    In a COS project the Hull data is in the Hull subfolder of the Outfitting project <ProjectName>.pms. If the <ProjectName>.pms folder is passed to Hull Clone without the Hull subfolder, the tool will automatically add it.

  • The Hullcentre path is set in the environment by wrapping the execution of the script in a small batch file.

    Hullcentre is typically on a network location. The path may be given using a mapped drive letter or as a fully qualified UNC path. Also the path to the distributed Hull project can either be a mapped folder, or a fully qualified UNC path.

The same batch file is used to set the %DM_NLC_HOST% environment variable that tells the Hull Clone program where the license server can be found.

Example script

This example script recalculates the inner structure in the checked-out blocks. It showcases how we can interact with the Hull COS Agent (HCA) using the system() command, and then recalculate all inner structure in the blocks that are checked out at our site. Also note how the script defines functions which can already be used before they are defined in the script file.

Th script performs the following steps:

  • Collect blocks that have 3D data and that are not virtual.

  • Check the COS status of each selected block.
    • Select blocks that are checked out for recalculation.

    • Skip blocks that are checked out at a different site.

    • Try to check out blocks that are not checked out anywhere (free blocks). If successful, select the blocks for recalculation.

  • Recalculate selected blocks.

  • Save construction of blocks that were already checked out to our site.

  • Check in blocks we implicitly checked out in preceding steps.

Notes on the script:

  • The different hcc commands only start the COS operation. The hcc progress special command can be used to wait for queued and unfinished commands.

  • Take special note of the leaveActiveBlock() call. The Hull Clone process appears as a normal Hull user to the system, and therefore the HCA is not allowed to execute COS actions in a block if a Hull Clone process is active in that block. Therefore we need to (temporarily) leave the last recalculated block to ensure that the subsequent save or check in action succeeds.