Please enable JavaScript to view this site.

QPR Knowledge Base 2023.1

  •      
  • Navigation: Developer's Guide > QPR API > The Object Model > QPR Modeling > PGModel Commands

    CreateInstance

    Scroll Prev Top Next More

    Revision history:

    Introduced in QPR 8.0

    Last changed in QPR 2012.2

     

    Creates a new element instance and returns the FullId (String) = <Id>.<InstanceId> of the created instance.

     

    Synopsis:

     

    PGModel.CreateInstance(ElementId, Parameters, out FullId)

     

    Parameters:

     

    ElementId: Integer. Id of the element to be instantiated.

    Parameters: A semicolon-separated list of parameters for creating a new element instance. The supported parameters:

    ProcessLevel=<PS level Id>: Defines the diagram where the instance is created. If omitted, the instance is created under the main diagram.

    OrganizationUnit=<Organization Unit ID>: Defines the organization unit where the instance is created. Note that the organization unit must be instantiated to the diagram that is defined with the ProcessLevel= parameter. Instance graphical properties are set automatically so that instance is placed inside the Organization unit lanes.

    InstanceGraphicalProperties=<startpoint.X>,<startpoint.Y>,<height>,<width>: Defines the graphical position and size of the instance. Some of the properties can be separately left empty. However, both <startpoint.X> and <startpoint.Y> must be set if position is needed to be set. If <startpoint.X> and <startpoint.Y> are set, these override the possible automatic Organization unit placement.

    FullId (String) = <Id>.<InstanceID> of the created instance.

     

    Required Rights:

     

    Modify rights to the diagram.

     

    Return Values:

    Below are listed the return values that this function can return:

     

    RV_SUCCESS

    RV_MODEL_NOT_OPEN

    RV_ELEMENT_NOT_FOUND

    RV_CANNOT_CREATE_ELEMENT

    RV_INVALID_PARAMETER

    RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

     

    Example Procedure:

     

    iResult = PGModel.CreateInstance(12345, "InstanceGraphicalProperties=1050,800,100,150;", FId)

    'Creates a new instance of the element with Id 12345, sets the graphical properties for the instance. Returns the FullId of the new instance in the form "12345.<InstanceId>'