Xrefs class

The Xrefs class gives you access to cross references. More...

The PRIMER JavaScript API provides many class constants, properties and methods. For Arup to be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:

Member functions

Xrefs properties

Name Type Description
numtypes (read only) integer The number of different types that this item is referenced by.
total (read only) integer The total number of cross references of all types to this item.

Detailed Description

The Xrefs class allows you to look at what things use an item. e.g. a node may be used on several shells. See the documentation below for more details.

Details of functions

GetID(type[string], pos[integer])   [deprecated]

This function is deprecated in version 10.0. It is only provided to keep old scripts working. We strongly advise against using it in new scripts. Support may be removed in future versions.

Description

Use Xrefs.GetItemID() instead.

Arguments

  • type (string)

    Use Xrefs.GetItemID() instead.

  • pos (integer)

    Use Xrefs.GetItemID() instead.

    Returns

    No return value


    GetItemID(type[string], pos[integer])

    Description

    Returns the ID of the item in the reference list.

    Arguments

  • type (string)

    The type of the item in the reference list (for a list of types see Appendix I of the PRIMER manual).

  • pos (integer)

    The position in the list for this item. Note that positions start at 0, not 1

    Returns

    ID of item

    Return type

    Number

    Example

    To list all of the xrefs for node n:

    var xrefs = n.Xrefs();
    for (var t=0; t<xrefs.numtypes; t++)
    {
        var type = xrefs.GetType(t);
        var num  = xrefs.GetTotal(type);
        for (var ref=0; ref<num; ref++)
        {
            var id = xrefs.GetItemID(type, ref);
            Message(type + " " + id + "\n");
        }
    }
    


    GetItemType(type[string], pos[integer])

    Description

    Returns the type of the item in the reference list. This function is only required when trying to look at cross references to *DEFINE_CURVE items. These items are used in a slightly different way in PRIMER (each time a curve is used a 'LOADCURVE REFERENCE' structure is created to store things like the units and descriptions of each axis for the curve). If you try to get the cross references for a curve all the references will be of type 'LOADCURVE REFERENCE' and numtypes will be 1. GetItemID() will correctly return the ID of the item from the 'LOADCURVE REFERENCE' structure but to get the type of the item this function is required.

    Arguments

  • type (string)

    The type of the item in the reference list (for a list of types see Appendix I of the PRIMER manual).

  • pos (integer)

    The position in the list for this item. Note that positions start at 0, not 1

    Returns

    type of item (String). For every item apart from *DEFINE_CURVE items this will be the same as the type argument.

    Return type

    String

    Example

    To list all of the xrefs for Curve c:

    var xrefs = c.Xrefs();
    for (var t=0; t<xrefs.numtypes; t++)
    {
        var type = xrefs.GetType(t);
        var num  = xrefs.GetTotal(type);
        for (var ref=0; ref<num; ref++)
        {
            var id = xrefs.GetItemID(type, ref);
            var itype = xrefs.GetItemType(type, ref);
            Message(itype + " " + id + "\n");
        }
    }
    


    GetTotal(type[string])

    Description

    Returns the total number of references of a type.

    Arguments

  • type (string)

    The type of the item in the reference list (for a list of types see Appendix I of the PRIMER manual).

    Returns

    Number of refs (integer)

    Return type

    Number

    Example

    To find the total number of shell references that node n has:

    var xrefs = n.Xrefs();
        var num  = xrefs.GetTotal("SHELL");
    


    GetType(n[integer])

    Description

    Returns the type for an entry in the reference list. Note that for a curve all the references will be of type 'LOADCURVE REFERENCE' and numtypes will be 1. See GetItemType() for more details.

    Arguments

  • n (integer)

    The entry in the reference types that you want the type for. Note that entries start at 0, not 1

    Returns

    The type of the item (string)

    Return type

    String

    Example

    To list the types of items that have cross references for node n:

    var xrefs = n.Xrefs();
    for (var t=0; t<xrefs.numtypes; t++)
    {
        var type = xrefs.GetType(t);
        var num  = xrefs.GetTotal(type);
        Message(num + " references of type " + type + "\n");
    }