Part class

The Part class gives you access to part cards in PRIMER. 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:

Class functions

Member functions

Part properties

Name Type Description
adpopt integer Adaptivity flag
ansid integer Attachment node set ID
attachment_nodes logical If _ATTACHMENT_NODES option is set. Can be true or false
averaged logical If _AVERAGED option is set. Can be true or false
cadname string CAD name stored for Part (or null if doesn't exist). This property is only used by PRIMER.
cid integer Coordinate system number
cmsn integer CAL3D/MADYMO number
colour Colour The colour of the part
composite logical If _COMPOSITE option is set. Can be true or false
composite_long logical If _COMPOSITE_LONG option is set. Can be true or false
contact logical If _CONTACT option is set. Can be true or false
dc real Exponential decay coefficient
element_type (read only) string The type of elements the Part contains. e.g. "SHELL", "SOLID" or null if empty/no section.
elform integer Element formulation
eosid integer or string Equation of state number or character label
exists (read only) logical true if part exists, false if referred to but not defined.
fd real Dynamic coefficient of friction
fs real Static coefficient of friction
grav integer Gravity loading
heading string Part heading
hgid integer or string Hourglass number or character label
hmname string Hypermesh comment read from keyword file for Part (or null if doesn't exist).
iga_shell logical If _COMPOSITE_IGA_SHELL option is set. Can be true or false
include integer The Include file number that the part is in.
inertia logical If _INERTIA option is set. Can be true or false
ircs integer Flag for inertia tensor reference coordinate system
irl integer Lamina integration rule
ixx real Ixx component of inertia tensor
ixy real Ixy component of inertia tensor
ixz real Ixz component of inertia tensor
iyy real Iyy component of inertia tensor
iyz real Iyz component of inertia tensor
izz real Izz component of inertia tensor
label integer or string Part number or character label. Also see the pid property which is an alternative name for this.
marea real Non structural mass per unit area
mdep integer MADYMO ellipse/plane number
mid integer or string Material number or character label
model (read only) integer The Model number that the part is in.
movopt integer Flag to deactivate moving for merged rigid bodies
nip integer Number of integration points (layers) present for _COMPOSITE parts
nloc integer Location of reference surface
nodeid integer Node ID for centre of rigid body
optt real Contact thickness
pid integer or string Part number or character label. Also see the label property which is an alternative name for this.
prbf integer Print flag for RBDOUT and MATSUM files
print logical If _PRINT option is set. Can be true or false
reposition logical If _REPOSITION option is set. Can be true or false
rigid (read only) logical true if part is rigid, false if deformable.
secid integer or string Section number or character label
sft real Thickness scale factor
shrf real Shear correction factor
ssf real Scale factor on default surfA penalty stiffness
thshel integer Thermal shell formulation
tm real total mass
tmid integer or string Thermal material number or character label
transparency integer The transparency of the part (0-100) 0% is opaque, 100% is transparent.
tshear integer Flag for transverse shear strain distribution
tshell logical If _COMPOSITE_TSHELL option is set. Can be true or false
vc real Coefficient for viscous friction
vrx real x rotational velocity
vry real y rotational velocity
vrz real z rotational velocity
vtx real x translational velocity
vty real y translational velocity
vtz real z translational velocity
xc real x coordinate of centre of mass
xl real x coordinate of local x axis
xlip real x coordinate of vector in local xy plane
yc real y coordinate of centre of mass
yl real y coordinate of local x axis
ylip real y coordinate of vector in local xy plane
zc real z coordinate of centre of mass
zl real z coordinate of local x axis
zlip real z coordinate of vector in local xy plane

Detailed Description

The Part class allows you to create, modify, edit and manipulate part cards. See the documentation below for more details.

Constructor

new Part(Model[Model], pid[integer or string], secid[integer or string], mid[integer or string], heading (optional)[string])

Description

Create a new Part object.

Arguments

  • Model (Model)

    Model that part will be created in

  • pid (integer or string)

    Part number or character label

  • secid (integer or string)

    Section number or character label

  • mid (integer or string)

    Material number or character label

  • heading (optional) (string)

    Title for the part

    Returns

    Part object

    Return type

    Part

    Example

    To create a new part called 'Example' in model m with label 100, section 1, material 10:

    var p = new Part(m, 100, 1, 10, 'Example');

    Details of functions

    AllTableProperties(Model[Model]) [static]

    Description

    Returns all of the properties available in the part table for the parts. The table values are returned in an array of objects (an object for each part). The object property names are the same as the table headers but spaces are replaced with underscore characters and characters other than 0-9, a-z and A-Z are removed to ensure that the property name is valid in JavaScript. If a table value is undefined the property value will be the JavaScript undefined value. If the table value is a valid number it will be a number, otherwise the value will returned as a string.

    Arguments

  • Model (Model)

    Model that the flagged parts are in

    Returns

    Array of objects

    Return type

    Array

    Example

    To get all of the properties for parts in model m:

    var properties = Part.AllTableProperties(m);
    for (var p=0; p<properties.length; p++)
    {
        for (var x in properties[p])
        {
            Message(x+"="+properties[p][x]);
        }
    }


    AssociateComment(Comment[Comment])

    Description

    Associates a comment with a part.

    Arguments

  • Comment (Comment)

    Comment that will be attached to the part

    Returns

    No return value

    Example

    To associate comment c to the part p:

    p.AssociateComment(c);


    Blank()

    Description

    Blanks the part

    Arguments

    No arguments

    Returns

    No return value

    Example

    To blank part p:

    p.Blank();


    BlankAll(Model[Model], redraw (optional)[boolean]) [static]

    Description

    Blanks all of the parts in the model.

    Arguments

  • Model (Model)

    Model that all parts will be blanked in

  • redraw (optional) (boolean)

    If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().

    Returns

    No return value

    Example

    To blank all of the parts in model m:

    Part.BlankAll(m);


    BlankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]

    Description

    Blanks all of the flagged parts in the model.

    Arguments

  • Model (Model)

    Model that all the flagged parts will be blanked in

  • flag (Flag)

    Flag set on the parts that you want to blank

  • redraw (optional) (boolean)

    If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().

    Returns

    No return value

    Example

    To blank all of the parts in model m flagged with f:

    Part.BlankFlagged(m, f);


    Blanked()

    Description

    Checks if the part is blanked or not.

    Arguments

    No arguments

    Returns

    true if blanked, false if not.

    Return type

    Boolean

    Example

    To check if part p is blanked:

    if (p.Blanked() ) do_something...


    Browse(modal (optional)[boolean])

    Description

    Starts an edit panel in Browse mode.

    Arguments

  • modal (optional) (boolean)

    If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.

    Returns

    no return value

    Example

    To Browse part p:

    p.Browse();


    CentreOfGravity(options (optional)[object])

    Description

    Returns the centre of gravity for a part.

    Arguments

  • options (optional) (object)

    Options specifying how the mass calculation should be done.

    Object has the following properties:

    Name Type Description
    constrainedparts (optional) boolean Mass of rigid lead part includes mass of its constrained parts. On by default.
    lumpedmass (optional) boolean Lumped mass is included for deformable parts. Off by default.
    nrbmass (optional) boolean NRB mass is included for deformable parts. Off by default. (tranfermass:true required for this option)
    plot (optional) boolean Plot CofG.
    skipconstrained (optional) boolean Constrained rigid part is assigned zero mass (if constrainedparts = true). On by default.
    timestepmass (optional) boolean Timestep added mass is included for deformable parts. Off by default.
    transfermass (optional) boolean Mass of deformable nodes attached to rigid part/nrb is transferred. On by default.

    Returns

    An array containing the x, y and z coordinates for the CofG.

    Return type

    Array

    Example

    To get the centre of gravity for part p with options configured:

    var cofg = p.CentreOfGravity({constrainedparts:false, transfermass:true, lumpedmass:false, nrbmass:true, timestepmass:false, plot:true});
    var x = cofg[0];
    var y = cofg[1];
    var z = cofg[2];
          


    CentreOfGravity(option (optional)[boolean])   [deprecated]

    This function is deprecated in version 16.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

    Returns the centre of gravity for a part. Rigid parts will always include mass of constrained parts.
    Mass is transferred from deformable to rigid when nodes attach.

    Arguments

  • option (optional) (boolean)

    If set, centre of gravity calculation for deformable parts includes lumped mass, mass of nodal rigid bodies and timestep added mass.

    Returns

    An array containing the x, y and z coordinates for the CofG.

    Return type

    Array

    Example

    To get the centre of gravity for part p:

    var cofg = p.CentreOfGravity();
                var x = cofg[0];
                var y = cofg[1];
                var z = cofg[2];
          


    ClearFlag(flag[Flag])

    Description

    Clears a flag on the part.

    Arguments

  • flag (Flag)

    Flag to clear on the part

    Returns

    No return value

    Example

    To clear flag f for part p:

    p.ClearFlag(f);


    ClosestNode(x[real], y[real], z[real])

    Description

    Finds the Node on the part closest to a coordinate.

    Arguments

  • x (real)

    X coordinate of point

  • y (real)

    Y coordinate of point

  • z (real)

    Z coordinate of point

    Returns

    ID of Node or null if part has no nodes

    Return type

    Number

    Example

    To find the node on part p closest to point (1, 2, 3):

    var n = p.ClosestNode(1, 2, 3);


    Copy(range (optional)[boolean])

    Description

    Copies the part. The target include of the copied part can be set using Options.copy_target_include.

    Arguments

  • range (optional) (boolean)

    If you want to keep the copied item in the range specified for the current include. Default value is false. To set current include, use Include.MakeCurrentLayer().

    Returns

    Part object

    Return type

    Part

    Example

    To copy part p into part z:

    var z = p.Copy();


    Create(Model[Model], modal (optional)[boolean]) [static]

    Description

    Starts an interactive editing panel to create a part

    Arguments

  • Model (Model)

    Model that the part will be created in.

  • modal (optional) (boolean)

    If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.

    Returns

    Part object (or null if not made).

    Return type

    Part

    Example

    To start creating a part in model m:

    var p = Part.Create(m);


    DetachComment(Comment[Comment])

    Description

    Detaches a comment from a part.

    Arguments

  • Comment (Comment)

    Comment that will be detached from the part

    Returns

    No return value

    Example

    To detach comment c from the part p:

    p.DetachComment(c);


    Edit(modal (optional)[boolean])

    Description

    Starts an interactive editing panel.

    Arguments

  • modal (optional) (boolean)

    If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.

    Returns

    no return value

    Example

    To Edit part p:

    p.Edit();


    Error(message[string], details (optional)[string])

    Description

    Adds an error for part. For more details on checking see the Check class.

    Arguments

  • message (string)

    The error message to give

  • details (optional) (string)

    An optional detailed error message

    Returns

    No return value

    Example

    To add an error message "My custom error" for part p:

    p.Error("My custom error");


    ExtractColour()

    Description

    Extracts the actual colour used for part.
    By default in PRIMER many entities such as elements get their colour automatically from the part that they are in. PRIMER cycles through 13 default colours based on the label of the entity. In this case the part colour property will return the value Colour.PART instead of the actual colour. This method will return the actual colour which is used for drawing the part.

    Arguments

    No arguments

    Returns

    colour value (integer)

    Return type

    Number

    Example

    To return the colour used for drawing part p:

    var colour = p.ExtractColour();


    First(Model[Model]) [static]

    Description

    Returns the first part in the model.

    Arguments

  • Model (Model)

    Model to get first part in

    Returns

    Part object (or null if there are no parts in the model).

    Return type

    Part

    Example

    To get the first part in model m:

    var p = Part.First(m);


    FirstFreeLabel(Model[Model], layer (optional)[Include number]) [static]

    Description

    Returns the first free part label in the model. Also see Part.LastFreeLabel(), Part.NextFreeLabel() and Model.FirstFreeItemLabel().

    Arguments

  • Model (Model)

    Model to get first free part label in

  • layer (optional) (Include number)

    Include file (0 for the main file) to search for labels in (Equivalent to First free in layer in editing panels). If omitted the whole model will be used (Equivalent to First free in editing panels).

    Returns

    Part label.

    Return type

    Number

    Example

    To get the first free part label in model m:

    var label = Part.FirstFreeLabel(m);


    FlagAll(Model[Model], flag[Flag]) [static]

    Description

    Flags all of the parts in the model with a defined flag.

    Arguments

  • Model (Model)

    Model that all parts will be flagged in

  • flag (Flag)

    Flag to set on the parts

    Returns

    No return value

    Example

    To flag all of the parts with flag f in model m:

    Part.FlagAll(m, f);


    FlagVisible(Model[Model], flag[Flag]) [static]

    Description

    Flags all the unblanked parts in the model.

    Arguments

  • Model (Model)

    Model for which all unblanked parts will be flagged in

  • flag (Flag)

    Flag to set on the unblanked parts

    Returns

    No return value

    Example

    To flag all unblanked parts in model m with flag f:

    Part.FlagVisible(m, f);


    Flagged(flag[Flag])

    Description

    Checks if the part is flagged or not.

    Arguments

  • flag (Flag)

    Flag to test on the part

    Returns

    true if flagged, false if not.

    Return type

    Boolean

    Example

    To check if part p has flag f set on it:

    if (p.Flagged(f) ) do_something...


    FlaggedTableProperties(Model[Model], flag[Flag]) [static]

    Description

    Returns all of the properties available in the part table for the flagged parts. The table values are returned in an array of objects (an object for each part). The object property names are the same as the table headers but spaces are replaced with underscore characters and characters other than 0-9, a-z and A-Z are removed to ensure that the property name is valid in JavaScript. If a table value is undefined the property value will be the JavaScript undefined value. If the table value is a valid number it will be a number, otherwise the value will returned as a string.

    Arguments

  • Model (Model)

    Model that the flagged parts are in

  • flag (Flag)

    Flag set on the parts that you want properties for

    Returns

    Array of objects

    Return type

    Array

    Example

    To get all of the properties for parts in model m flagged with f:

    var properties = Part.FlaggedTableProperties(m, f);
    for (var p=0; p<properties.length; p++)
    {
        for (var x in properties[p])
        {
            Message(x+"="+properties[p][x]);
        }
    }


    ForEach(Model[Model], func[function], extra (optional)[any]) [static]

    Description

    Calls a function for each part in the model.
    Note that ForEach has been designed to make looping over parts as fast as possible and so has some limitations.
    Firstly, a single temporary Part object is created and on each function call it is updated with the current part data. This means that you should not try to store the Part object for later use (e.g. in an array) as it is temporary.
    Secondly, you cannot create new parts inside a ForEach loop.

    Arguments

  • Model (Model)

    Model that all parts are in

  • func (function)

    Function to call for each part

  • extra (optional) (any)

    An optional extra object/array/string etc that will appended to arguments when calling the function

    Returns

    No return value

    Example

    To call function test for all of the parts in model m:

    Part.ForEach(m, test);
    function test(p)
    {
    // p is Part object
    }

    To call function test for all of the parts in model m with optional object:

    var data = { x:0, y:0 };
    Part.ForEach(m, test, data);
    function test(p, extra)
    {
    // p is Part object
    // extra is data
    }


    GetAll(Model[Model], property (optional)[string]) [static]

    Description

    Returns an array of Part objects or properties for all of the parts in a model in PRIMER. If the optional property argument is not given then an array of Part objects is returned. If the property argument is given, that property value for each part is returned in the array instead of a Part object

    Arguments

  • Model (Model)

    Model to get parts from

  • property (optional) (string)

    Name for property to get for all parts in the model

    Returns

    Array of Part objects or properties

    Return type

    Array

    Example

    To make an array of Part objects for all of the parts in model m:

    var a = Part.GetAll(m);

    To return an array containing the value of property 'foo' (for example 'x' for a node) for each part in model m:

    var a = Part.GetAll(m, 'foo');


    GetComments()

    Description

    Extracts the comments associated to a part.

    Arguments

    No arguments

    Returns

    Array of Comment objects (or null if there are no comments associated to the node).

    Return type

    Array

    Example

    To get the array of comments associated to the part p:

    var comm_array = p.GetComments();


    GetCompositeData(ipt[integer])

    Description

    Returns the composite data for an integration point in *PART_COMPOSITE.

    Arguments

  • ipt (integer)

    The integration point you want the data for. Note that integration points start at 0, not 1.

    Returns

    An array containing the material id, thickness, beta angle and thermal material values. If the _COMPOSITE_LONG option is set, then the array returned will also contain the ply ID.

    Return type

    Array

    Example

    To get the composite data for the 3rd integration point for part p:

    if (p.composite && p.nip >= 3)
    {
        var ipt_data = p.GetCompositeData(2);
    }


    GetFlagged(Model[Model], flag[Flag], property (optional)[string]) [static]

    Description

    Returns an array of Part objects for all of the flagged parts in a model in PRIMER If the optional property argument is not given then an array of Part objects is returned. If the property argument is given, then that property value for each part is returned in the array instead of a Part object

    Arguments

  • Model (Model)

    Model to get parts from

  • flag (Flag)

    Flag set on the parts that you want to retrieve

  • property (optional) (string)

    Name for property to get for all flagged parts in the model

    Returns

    Array of Part objects or properties

    Return type

    Array

    Example

    To make an array of Part objects for all of the parts in model m flagged with f:

    var p = Part.GetFlagged(m, f);

    To return an array containing the value of property 'foo' (for example 'x' for a node) for all of the parts in model m flagged with f:

    var a = Part.GetFlagged(m, f, 'foo');


    GetFromID(Model[Model], number[integer]) [static]

    Description

    Returns the Part object for a part ID.

    Arguments

  • Model (Model)

    Model to find the part in

  • number (integer)

    number of the part you want the Part object for

    Returns

    Part object (or null if part does not exist).

    Return type

    Part

    Example

    To get the Part object for part 100 in model m

    var p = Part.GetFromID(m, 100);


    GetParameter(prop[string])

    Description

    Checks if a Part property is a parameter or not. Note that object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. For this function to work the JavaScript interpreter must use the parameter name instead of the value. This can be done by setting the Options.property_parameter_names option to true before calling the function and then resetting it to false afterwards.. This behaviour can also temporarily be switched by using the Part.ViewParameters() method and 'method chaining' (see the examples below).

    Arguments

  • prop (string)

    part property to get parameter for

    Returns

    Parameter object if property is a parameter, null if not.

    Return type

    Parameter

    Example

    To check if Part property p.example is a parameter:

    Options.property_parameter_names = true;
    if (p.GetParameter(p.example) ) do_something...
    Options.property_parameter_names = false;

    To check if Part property p.example is a parameter by using the GetParameter method:

    if (p.ViewParameters().GetParameter(p.example) ) do_something...


    Keyword()

    Description

    Returns the keyword for this part (*PART, *PART_SCALAR or *PART_SCALAR_VALUE). Note that a carriage return is not added. See also Part.KeywordCards()

    Arguments

    No arguments

    Returns

    string containing the keyword.

    Return type

    String

    Example

    To get the keyword for part p:

    var key = p.Keyword();


    KeywordCards()

    Description

    Returns the keyword cards for the part. Note that a carriage return is not added. See also Part.Keyword()

    Arguments

    No arguments

    Returns

    string containing the cards.

    Return type

    String

    Example

    To get the cards for part p:

    var cards = p.KeywordCards();


    Last(Model[Model]) [static]

    Description

    Returns the last part in the model.

    Arguments

  • Model (Model)

    Model to get last part in

    Returns

    Part object (or null if there are no parts in the model).

    Return type

    Part

    Example

    To get the last part in model m:

    var p = Part.Last(m);


    LastFreeLabel(Model[Model], layer (optional)[Include number]) [static]

    Description

    Returns the last free part label in the model. Also see Part.FirstFreeLabel(), Part.NextFreeLabel() and see Model.LastFreeItemLabel()

    Arguments

  • Model (Model)

    Model to get last free part label in

  • layer (optional) (Include number)

    Include file (0 for the main file) to search for labels in (Equivalent to Highest free in layer in editing panels). If omitted the whole model will be used.

    Returns

    Part label.

    Return type

    Number

    Example

    To get the last free part label in model m:

    var label = Part.LastFreeLabel(m);


    Mass()

    Description

    Returns the mass properties for a part.

    Arguments

    No arguments

    Returns

    Object with the following properties:

    Name Type Description
    Assign_Mass real Assign mass
    Component_Mass real Component mass
    Dyna_Added_Mass real Dyna added mass
    Dyna_Part_Mass real Dyna part mass
    Lumped_Mass real Lumped mass
    NRB_Mass real NRB mass
    NS_Mass real Non-structural mass
    Struct_Mass real Structural mass
    Transferrd_Mass real Transferred mass when deformable meshed to rigid

    Return type

    object

    Example

    To get the structural mass for part p:

    var mprops = p.Mass();
                            var struct_mass = mprops.Struct_Mass;


    MaxMin()

    Description

    Returns the max and min bounds of a part

    Arguments

    No arguments

    Returns

    An array containing the xMin, xMax, yMin, yMax, zMin and zMax coordinates for a box bounding the part, or null if the bounds cannot be calculated (e.g. the part has no structural elements)

    Return type

    array

    Example

    To get the bounds for part p:

    var bounds = p.MaxMin();
    if (bounds) {
        xMin = bounds[0];
        xMax = bounds[1];
        yMin = bounds[2];
        yMax = bounds[3];
        zMin = bounds[4];
        zMax = bounds[5];
    }
    


    MeasurePartToPart(part1[Part], part2[Part]) [static]

    Description

    This static method measures the distance between two part objects contained in the same model or in two different models

    Arguments

  • part1 (Part)

    Part to measure from

  • part2 (Part)

    Part to measure to

    Returns

    Object with the following properties:

    Name Type Description
    distance real Distance between the two parts
    vector Array of reals Components of distance vector

    Return type

    object

    Example

    To measure the distance between part object p1 and part object p2:

    var m = Part.MeasurePartToPart(p1, p2);
    var d = m.distance;
    var XComp = m.vector[0];
    var YComp = m.vector[1];
    var ZComp = m.vector[2];


    Next()

    Description

    Returns the next part in the model.

    Arguments

    No arguments

    Returns

    Part object (or null if there are no more parts in the model).

    Return type

    Part

    Example

    To get the part in model m after part p:

    var p = p.Next();


    NextFreeLabel(Model[Model], layer (optional)[Include number]) [static]

    Description

    Returns the next free (highest+1) part label in the model. Also see Part.FirstFreeLabel(), Part.LastFreeLabel() and Model.NextFreeItemLabel()

    Arguments

  • Model (Model)

    Model to get next free part label in

  • layer (optional) (Include number)

    Include file (0 for the main file) to search for labels in (Equivalent to Highest+1 in layer in editing panels). If omitted the whole model will be used (Equivalent to Highest+1 in editing panels).

    Returns

    Part label.

    Return type

    Number

    Example

    To get the next free part label in model m:

    var label = Part.NextFreeLabel(m);


    Pick(prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean], button text (optional)[string]) [static]

    Description

    Allows the user to pick a part.

    Arguments

  • prompt (string)

    Text to display as a prompt to the user

  • limit (optional) (Model or Flag)

    If the argument is a Model then only parts from that model can be picked. If the argument is a Flag then only parts that are flagged with limit can be selected. If omitted, or null, any parts from any model can be selected. from any model.

  • modal (optional) (boolean)

    If picking is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the pick will be modal.

  • button text (optional) (string)

    By default the window with the prompt will have a button labelled 'Cancel' which if pressed will cancel the pick and return null. If you want to change the text on the button use this argument. If omitted 'Cancel' will be used.

    Returns

    Part object (or null if not picked)

    Return type

    Part

    Example

    To pick a part from model m giving the prompt 'Pick part from screen':

    var p = Part.Pick('Pick part from screen', m);


    Previous()

    Description

    Returns the previous part in the model.

    Arguments

    No arguments

    Returns

    Part object (or null if there are no more parts in the model).

    Return type

    Part

    Example

    To get the part in model m before part p:

    var p = p.Previous();


    RemoveCompositeData(ipt[integer])

    Description

    Removes the composite data for an integration point in *PART_COMPOSITE.

    Arguments

  • ipt (integer)

    The integration point you want to remove. Note that integration points start at 0, not 1.

    Returns

    No return value.

    Example

    To remove the composite data for the 3rd integration point for part p:

    p.RemoveCompositeData(2);


    RenumberAll(Model[Model], start[integer]) [static]

    Description

    Renumbers all of the parts in the model.

    Arguments

  • Model (Model)

    Model that all parts will be renumbered in

  • start (integer)

    Start point for renumbering

    Returns

    No return value

    Example

    To renumber all of the parts in model m, from 1000000:

    Part.RenumberAll(m, 1000000);


    RenumberFlagged(Model[Model], flag[Flag], start[integer]) [static]

    Description

    Renumbers all of the flagged parts in the model.

    Arguments

  • Model (Model)

    Model that all the flagged parts will be renumbered in

  • flag (Flag)

    Flag set on the parts that you want to renumber

  • start (integer)

    Start point for renumbering

    Returns

    No return value

    Example

    To renumber all of the parts in model m flagged with f, from 1000000:

    Part.RenumberFlagged(m, f, 1000000);


    Select(flag[Flag], prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean]) [static]

    Description

    Allows the user to select parts using standard PRIMER object menus.

    Arguments

  • flag (Flag)

    Flag to use when selecting parts

  • prompt (string)

    Text to display as a prompt to the user

  • limit (optional) (Model or Flag)

    If the argument is a Model then only parts from that model can be selected. If the argument is a Flag then only parts that are flagged with limit can be selected (limit should be different to flag). If omitted, or null, any parts can be selected. from any model.

  • modal (optional) (boolean)

    If selection is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the selection will be modal.

    Returns

    Number of parts selected or null if menu cancelled

    Return type

    Number

    Example

    To select parts from model m, flagging those selected with flag f, giving the prompt 'Select parts':

    Part.Select(f, 'Select parts', m);

    To select parts, flagging those selected with flag f but limiting selection to parts flagged with flag l, giving the prompt 'Select parts':

    Part.Select(f, 'Select parts', l);


    SetCompositeData(ipt[integer], mid[integer], thick[real], beta[real], tmid (optinal)[integer], plyid (optional)[integer], shrfac (optional)[real])

    Description

    Sets the composite data for an integration point in *PART_COMPOSITE.

    Arguments

  • ipt (integer)

    The integration point you want to set the data for. Note that integration points start at 0, not 1.

  • mid (integer)

    Material ID for the integration point.

  • thick (real)

    Thickness of the integration point.

  • beta (real)

    Material angle of the integration point.

  • tmid (optinal) (integer)

    Thermal material ID for the integration point.

  • plyid (optional) (integer)

    Ply ID for the integration point. This should be used if the _COMPOSITE_LONG option is set for the part.

  • shrfac (optional) (real)

    Transverse shear stress scale factor.

    Returns

    No return value.

    Example

    To set the composite data for the 3rd integration point to mat 1, thickness 0.5 and angle 45, for part p:

    p.SetCompositeData(2, 1, 0.5, 45);


    SetFlag(flag[Flag])

    Description

    Sets a flag on the part.

    Arguments

  • flag (Flag)

    Flag to set on the part

    Returns

    No return value

    Example

    To set flag f for part p:

    p.SetFlag(f);


    Sketch(redraw (optional)[boolean])

    Description

    Sketches the part. The part will be sketched until you either call Part.Unsketch(), Part.UnsketchAll(), Model.UnsketchAll(), or delete the model

    Arguments

  • redraw (optional) (boolean)

    If model should be redrawn or not after the part is sketched. If omitted redraw is true. If you want to sketch several parts and only redraw after the last one then use false for redraw and call View.Redraw().

    Returns

    No return value

    Example

    To sketch part p:

    p.Sketch();


    SketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]

    Description

    Sketches all of the flagged parts in the model. The parts will be sketched until you either call Part.Unsketch(), Part.UnsketchFlagged(), Model.UnsketchAll(), or delete the model

    Arguments

  • Model (Model)

    Model that all the flagged parts will be sketched in

  • flag (Flag)

    Flag set on the parts that you want to sketch

  • redraw (optional) (boolean)

    If model should be redrawn or not after the parts are sketched. If omitted redraw is true. If you want to sketch flagged parts several times and only redraw after the last one then use false for redraw and call View.Redraw().

    Returns

    No return value

    Example

    To sketch all parts flagged with flag in model m:

    Part.SketchFlagged(m, flag);


    TableProperties()

    Description

    Returns all of the properties available for the part in the part table. The table values are returned in an object. The object property names are the same as the table headers but spaces are replaced with underscore characters and characters other than 0-9, a-z and A-Z are removed to ensure that the property name is valid in JavaScript. If a table value is undefined the property value will be the JavaScript undefined value. If the table value is a valid number it will be a number, otherwise the value will returned as a string.

    Arguments

    No arguments

    Returns

    object.

    Return type

    Object

    Example

    To get all of the properties for part p:

    var properties = p.TableProperties();
    for (var x in properties)
    {
        Message(x+"="+properties[x]);
    }


    Total(Model[Model], exists (optional)[boolean]) [static]

    Description

    Returns the total number of parts in the model.

    Arguments

  • Model (Model)

    Model to get total for

  • exists (optional) (boolean)

    true if only existing parts should be counted. If false or omitted referenced but undefined parts will also be included in the total.

    Returns

    number of parts

    Return type

    Number

    Example

    To get the total number of parts in model m:

    var total = Part.Total(m);


    Unblank()

    Description

    Unblanks the part

    Arguments

    No arguments

    Returns

    No return value

    Example

    To unblank part p:

    p.Unblank();


    UnblankAll(Model[Model], redraw (optional)[boolean]) [static]

    Description

    Unblanks all of the parts in the model.

    Arguments

  • Model (Model)

    Model that all parts will be unblanked in

  • redraw (optional) (boolean)

    If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().

    Returns

    No return value

    Example

    To unblank all of the parts in model m:

    Part.UnblankAll(m);


    UnblankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]

    Description

    Unblanks all of the flagged parts in the model.

    Arguments

  • Model (Model)

    Model that the flagged parts will be unblanked in

  • flag (Flag)

    Flag set on the parts that you want to unblank

  • redraw (optional) (boolean)

    If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().

    Returns

    No return value

    Example

    To unblank all of the parts in model m flagged with f:

    Part.UnblankFlagged(m, f);


    UnflagAll(Model[Model], flag[Flag]) [static]

    Description

    Unsets a defined flag on all of the parts in the model.

    Arguments

  • Model (Model)

    Model that the defined flag for all parts will be unset in

  • flag (Flag)

    Flag to unset on the parts

    Returns

    No return value

    Example

    To unset the flag f on all the parts in model m:

    Part.UnflagAll(m, f);


    Unsketch(redraw (optional)[boolean])

    Description

    Unsketches the part.

    Arguments

  • redraw (optional) (boolean)

    If model should be redrawn or not after the part is unsketched. If omitted redraw is true. If you want to unsketch several parts and only redraw after the last one then use false for redraw and call View.Redraw().

    Returns

    No return value

    Example

    To unsketch part p:

    p.Unsketch();


    UnsketchAll(Model[Model], redraw (optional)[boolean]) [static]

    Description

    Unsketches all parts.

    Arguments

  • Model (Model)

    Model that all parts will be unblanked in

  • redraw (optional) (boolean)

    If model should be redrawn or not after the parts are unsketched. If omitted redraw is true. If you want to unsketch several things and only redraw after the last one then use false for redraw and call View.Redraw().

    Returns

    No return value

    Example

    To unsketch all parts in model m:

    Part.UnsketchAll(m);


    UnsketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]

    Description

    Unsketches all flagged parts in the model.

    Arguments

  • Model (Model)

    Model that all parts will be unsketched in

  • flag (Flag)

    Flag set on the parts that you want to unsketch

  • redraw (optional) (boolean)

    If model should be redrawn or not after the parts are unsketched. If omitted redraw is true. If you want to unsketch several things and only redraw after the last one then use false for redraw and call View.Redraw().

    Returns

    No return value

    Example

    To unsketch all parts flagged with flag in model m:

    Part.UnsketchAll(m, flag);


    ViewParameters()

    Description

    Object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. This function temporarily changes the behaviour so that if a property is a parameter the parameter name is returned instead. This can be used with 'method chaining' (see the example below) to make sure a property argument is correct.

    Arguments

    No arguments

    Returns

    Part object.

    Return type

    Part

    Example

    To check if Part property p.example is a parameter by using the Part.GetParameter() method:

    if (p.ViewParameters().GetParameter(p.example) ) do_something...


    Warning(message[string], details (optional)[string])

    Description

    Adds a warning for part. For more details on checking see the Check class.

    Arguments

  • message (string)

    The warning message to give

  • details (optional) (string)

    An optional detailed warning message

    Returns

    No return value

    Example

    To add a warning message "My custom warning" for part p:

    p.Warning("My custom warning");


    Xrefs()

    Description

    Returns the cross references for this part.

    Arguments

    No arguments

    Returns

    Xrefs object.

    Return type

    Xrefs

    Example

    To get the cross references for part p:

    var xrefs = p.Xrefs();


    toString()

    Description

    Creates a string containing the part data in keyword format. Note that this contains the keyword header and the keyword cards. See also Part.Keyword() and Part.KeywordCards().

    Arguments

    No arguments

    Returns

    string

    Return type

    String

    Example

    To get data for part p in keyword format

    var str = p.toString();