PM_DEFINE_SET

Syntax

handle_val = PM_DEFINE_SET ( prompt[, flags][, type_mask, …] );
Input arguments
string prompt Prompt shown to the user.
Optional input arguments

int

flags

Additional conditions for object selection, defined as a sum of the required MMT_DEFSET_FLAGS_*** codes. The flags are defined in the header file %PMS_HOME%\include\pm_defs.h. The defined values are flag bits and they can be merged by giving the summed value for "flags" (effectively a bitwise or of the defined values) in the argument list.

For example, value 33 is the sum of the flag codes 1 and 32 which specify that (1) objects must be checked out to the user and that (32) dependent objects are to be selected regardless of their type.

This argument can be omitted, even when the "type_mask" argument is defined.

string type_mask Specifies the object type.

Return Values

Success:
handle   Handle of the set of objects.
Failure:
int 0 User canceled the operation or nothing was selected.

Description

This function starts the Plant Modeller define set function that prompts the user to select a set of objects and then returns a handle of the set. The set handle returned from this function can be later used to access member objects in the set.

The set should be freed via a call to the PM_FREE_SET extern when the set is no more needed in the script.

Optional arguments allow defining additional conditions for the selection (such as, are also dependent objects to be selected) and which object types are selectable.

Supported object types:

  • "3DSPACE"

  • "AIRDUCT" (obsolete, use HVACPART)

  • "ATTRIBUTE"

  • "BEAM"

  • "CABLE"

  • "CABLENETWORKPART"

  • "CABLETRAY"

  • "EQUIPMENT"

  • "GROUP"

  • "HOLEREQUEST"

  • "HULLCONSTRUCTIONPART"

  • "HVACPART"

  • "PIPE" (obsolete, use PIPINGPART)

  • "PIPINGPART"

  • "STANDCMP"

  • "STRUCTCMP"

  • "TEMPGEOM"

  • "WELD"

Examples

Only allow objects whose type is "PIPINGPART":

set = PM_DEFINE_SET("Define Set","PIPINGPART");

Allow any objects except those whose type is "PIPINGPART":

set = PM_DEFINE_SET("Define Set","!","PIPINGPART");

Only allow objects whose type is "AIRDUCT" or "BEAM" and which are checked out to the current user:

set = PM_DEFINE_SET("Define Set",1,"AIRDUCT","BEAM");

Copy
/*
**  This script lets the user to either:
**  1) copy the set of objects and then rotate the copied objects.
**  or
**  2) rotate objects in a set.
**  The input argument 'copy_before_rotation' is a boolean: if 1 then selected 
**  objects will be copied before they are rotated.
**  Objects of type "ATTRIBUTE", "GROUP" or "HOLEREQUEST" cannot be selected.
*/
#include include/dmutil.h
#include include/pm.h

main(int copy_before_rotation)
{    
    if (copy_before_rotation) {
        /*  
            1) Let the user select objects which can be copied
            2) Let only select objects which object type is not ATTRIBUTE or HOLEREQUEST 
        */
        flags = MMT_DEFSET_FLAGS_TEST_IF_CAN_BE_DUPLICATED;
        set_h = PM_DEFINE_SET("Objects to be Copied & Rotated", flags, "!", "ATTRIBUTE", "GROUP", "HOLEREQUEST");
    }
    else {
        flags = MMT_DEFSET_FLAGS_NEED_MODIFY_ACCESS;
        set_h = PM_DEFINE_SET("Objects to be Rotated", flags, "!", "ATTRIBUTE", "GROUP", "HOLEREQUEST");
     }

     if (set_h == 0) return(-1);
    
     rotate_set(copy_before_rotation, set_h);
     PM_FREE_SET(set_h);
}
rotate_set(int copy_before_rotation, handle set_h)
{
    /* do it... */
    return(0);
}