Model class

The Model class gives you access to models 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

Model constants

Constants for compress mode

Name Description
Model.INDIVIDUAL_GZIP Each file 'name.key' is 'gzipped' to become the individual file 'name.key.gz'
Model.INDIVIDUAL_ZIP Each file 'name.key' is 'zipped' to become the individual file 'name.key.zip'
Model.KEEP_ORIGINAL Each file 'name.key' is written using its original compression: uncompressed, '.gz. or '.zip' format
Model.PACKAGED_ZIP Suitable for models with include files where the entire model is packed into a single .zip file, preserving its directory structure.

Constants for compress switch

Name Description
Model.COMPRESS_KEEP Keeps the keyout compression format same as that of what was read in.
Model.COMPRESS_OFF Switches off compression during keyout.
Model.COMPRESS_ON Switches on compression during keyout.

Constants for filetype

Name Description
Model.ABAQUS ABAQUS input file
Model.IGES IGES 5.3 geometry file
Model.LSDYNA Ansys LS-DYNA keyword file
Model.NASTRAN NASTRAN bulk data file
Model.RADIOSS RADIOSS block format file

Constants for include deletion

Name Description
Model.REMOVE_FROM_SETS Only deletes items within the include selected but may remove items from sets in other includes.
Model.REMOVE_INCLUDE_ONLY Only deletes items within the include selected without removing items from sets in other includes.
Model.REMOVE_JUNIOR Delete items in other includes if they 'belong' to items in this include file but are considered to be 'junior' in the standard PRIMER hierarchy.

Constants for mass_properties_calculation

Name Description
Model.CENTRE_AT_COFG Uses the centre at centre of gravity in calculation of inertia properties.
Model.GLOBAL_AXES GLOBAL AXES
Model.LOCAL_AXES LOCAL AXES
Model.PRINCIPAL_AXES PRINCIPAL AXES
Model.USER_DEFINED_CENTRE Uses the user defined centre in calculation of inertia properties.

Constants for merge

Name Description
Model.DISCARD_PRIMARY_CLASH Merge option - discard primary items only on clash
Model.DISCARD_SECONDARY_CLASH Merge option - discard secondary items only on clash
Model.INCREASE_PRIMARY_ALWAYS Merge option - increase primary items always
Model.INCREASE_PRIMARY_CLASH Merge option - increase primary items only on clash
Model.INCREASE_SECONDARY_ALWAYS Merge option - increase secondary items always
Model.INCREASE_SECONDARY_CLASH Merge option - increase secondary items only on clash

Constants for renumber

Name Description
Model.IGNORE_CLASH Renumber option - Ignore clashes.
Model.MOVE_CLASH_UP Renumber option - Move clashing > highest label.
Model.RENUMBER_TO_FREE Renumber option - Renumber to next free label.
Model.SHIFT_ALL_UP Renumber option - Shift upwards to make space.

Constants for write hook

Name Description
Model.WRITE_DIALOGUE Flag that triggers the write hook script from the dialogue box
Model.WRITE_INCLUDE_TREE Flag that triggers the write hook script from the include file tree
Model.WRITE_MODEL Flag that triggers the write hook script from the model tab
Model.WRITE_SELECT_INCLUDES Flag that triggers the write hook script from the select include files panel

Model class properties

Name Type Description
highest (read only) integer The highest model number present in PRIMER

Model properties

Name Type Description
binary (read only) boolean If model is in binary then it will be 1(true) else 0(false).
comments string Comments stored at the top of the primary model file.
compress (read only) boolean If model is compressed then it will be 1(true) else 0(false).
compressMode (read only) integer This option can be used to know the mode of compression. Can be Model.INDIVIDUAL_GZIP or Model.INDIVIDUAL_ZIP or Model.PACKAGED_ZIP
control (read only) Control object Control cards for model. See Control for more details.
damping (read only) Damping object Damping cards for model. See Damping for more details.
database (read only) Database object Database cards for model. See Database for more details.
fileStartAscii (read only) boolean If the beginning of the master file (*CONTROL etc) is in ascii then 1(true) else 0(false)(NOTE: If master file is ascii then fileStartAscii won't be checked and show 0(false)).
filename (read only) string Name of file that model was read from (blank if model created)
id logical If ID flag set for *KEYWORD card
layer integer The current layer for the model. This is the label of the Include file or 0 for the main file. See also Include.MakeCurrentLayer()
loadBody (read only) LoadBody object LoadBody cards for model. See LoadBody for more details.
masterAscii (read only) boolean If master file is in ascii then 1(true) else 0(false).
num string Model num (for _ID)
number integer Model number
path (read only) string Path that model was read from (blank if model created)
project string Model project (for _ID)
readlog string Full path of the readlog file
stage string Model stage (for _ID)
title string Model title
visible logical Model visibility flag

Detailed Description

The Model class allows you to do various operations on models in PRIMER. There are various methods available that allow you do create, read, blank models etc. See the documentation below for more details.

Constructor

new Model(number (optional)[integer])

Description

Create a new model in PRIMER

Arguments

  • number (optional) (integer)

    Model number to create. If omitted the next free model number will be used.

    Returns

    Model object

    Return type

    Model

    Example

    To create a new model

    var m = new Model();

    To create model 10

    var m = new Model(10);

    Details of functions

    AreaVolumeFlagged(flag[Flag])

    Description

    Calculates the Area/Volume of the selected items.
    Note: The area calculation is based only on shell elements, and the volume calculation is based only on solid elements.

    Arguments

  • flag (Flag)

    Flag set on entities you wish to calculate area/volume for

    Returns

    Object with the following properties:

    Name Type Description
    area real Area of flagged items
    volume real Volume of flagged items

    Return type

    object

    Example

    To calculate the area/volume properties of the items flagged by flag f.

    var props = m.AreaVolumeFlagged(f);
    var area = props.area;
    var volume = props.volume;


    Attached(flag[Flag], redraw (optional)[boolean])

    Description

    Finds attached items to flagged items. The attached items are flagged with the same flag.

    Arguments

  • flag (Flag)

    Flag set on items that you want to find attached to

  • redraw (optional) (boolean)

    If true, the display will be updated to display only the original flagged items and the attached items.

    Returns

    No return value

    Example

    To find items attached to items flagged with flag f in model m:

    m.Attached(f);


    Autofix()

    Description

    Autofix option does a model check and autofixes all the fixable errors in the model

    Arguments

    No arguments

    Returns

    No return value

    Example

    To autofix fixable errors of the model 'm'

    m.Autofix();


    Blank()

    Description

    Blanks a model in PRIMER

    Arguments

    No arguments

    Returns

    No return value

    Example

    To blank model object m

    m.Blank();


    BlankAll() [static]

    Description

    Blanks all models

    Arguments

    No arguments

    Returns

    No return value

    Example

    To blank all models

    Model.BlankAll();


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

    Description

    Blanks all of the flagged items in the model.

    Arguments

  • flag (Flag)

    Flag set on items 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 everything in model m flagged with flag f:

    m.BlankFlagged(f);


    CentreOfGravity()

    Description

    Returns the centre of gravity for a model

    Arguments

    No arguments

    Returns

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

    Return type

    Array

    Example

    To get the centre of gravity for model m:

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


    Check(filename[string], detailed (optional)[boolean], json (optional)[boolean], include (optional)[boolean])

    Description

    Checks a model, writing any errors to file.

    Arguments

  • filename (string)

    Name of file to write errors to

  • detailed (optional) (boolean)

    If set to "true", detailed error messages are given.

  • json (optional) (boolean)

    If set, output in filename will be written in JSON format. If omitted json will be set to false. If JSON format is written then detailed will automatically be set. Note that when writing JSON format the labels produced can be strings instead of integers in some rare cases. If you are writing a script to read a JSON file, it must be able to cope with this. Specifically if the item is a character label the label will be a string. For child collect sets the label will be a string of the format 'X_Y' where X is the parent set label and Y will be the child set number (1, 2, 3 ...). In this case use Set.GetCollectChild() to get the object.

  • include (optional) (boolean)

    If set, error messages will be written in include by include layout. This option is not applicable if JSON is set.

    Returns

    No return value

    Example

    To check model m, writing detailed errors to file 'errors.txt' in include layout:

    m.Check('errors.txt', true, false, true);

    To check a model writing the warnings/errors as JSON to file 'errors.json', parse it and write them to the dialogue box:

    m.Check('errors.json', true, true);
    var f = new File('errors.json', File.READ);
    var json = f.ReadAll();
    f.Close();
    var o = JSON.parse(json);
    
    for (var e in o)                                     // "error" or "warning"
    {
        Message(e);
        for (var t in o[e])                              // type
        {
            Message("  "+t);
            for (var m in o[e][t])                       // message
            {
                Message("    "+m);
                for (var i=0; i<o[e][t][m].length; i++)  // Array of objects containing label and include
                {
                    Message("        "+o[e][t][m][i].label+" (include "+o[e][t][m][i].include+")");
                }
            }
        }
    }


    ClearFlag(flag[Flag])

    Description

    Clears the flagging for a model in PRIMER. See also Model.PropagateFlag(), Model.SetFlag(), global.AllocateFlag() and global.ReturnFlag().

    Arguments

  • flag (Flag)

    Flag to clear

    Returns

    No return value

    Example

    To clear flag f for everything in model m:

    m.ClearFlag(f);


    Copy(update (optional)[boolean])

    Description

    Copy model to the next free model in PRIMER

    Arguments

  • update (optional) (boolean)

    If the graphics should be updated after the model is copied. If omitted update will be set to false

    Returns

    Model object for new model.

    Return type

    Model

    Example

    To copy model m to the next free model in PRIMER.

    var mnew = m.Copy();


    CopyFlagged(flag[Flag], update (optional)[boolean])

    Description

    Copy flagged items in a model to the next free model in PRIMER

    Arguments

  • flag (Flag)

    Flag set on items that you want to copy

  • update (optional) (boolean)

    If the graphics should be updated after the model is copied. If omitted update will be set to false

    Returns

    Model object for new model.

    Return type

    Model

    Example

    To copy everything in model m flagged with flag f to the next free model in PRIMER.

    var mnew = m.CopyFlagged(f);


    Delete()

    Description

    Deletes a model in PRIMER
    Do not use the Model object after calling this method.

    Arguments

    No arguments

    Returns

    No return value

    Example

    To delete model m in PRIMER

    m.Delete();


    DeleteAll() [static]

    Description

    Deletes all existing models from PRIMER

    Arguments

    No arguments

    Returns

    No return value

    Example

    To delete all models

    Model.DeleteAll();


    DeleteFlagged(flag[Flag], recursive (optional)[boolean])

    Description

    Deletes all of the flagged items in the model. Note that this may not actually delete all of the items. For example if a node is flagged but the node is used in a shell which is not flagged then the node will not be deleted.

    Arguments

  • flag (Flag)

    Flag set on items that you want to delete

  • recursive (optional) (boolean)

    If deletion is recursive (for example, if a shell is deleted with recursion on the shell nodes will be deleted if possible). If omitted recursive will be set to true.

    Returns

    No return value

    Example

    To delete everything in model m flagged with flag f:

    m.DeleteFlagged(f);


    DeleteInclude(Include label[integer], method (optional)[constant], force (optional)[boolean])

    Description

    Tries to delete an include file from the model. Note that this may not actually delete the include file. For example if some of the items in the include file are required by other things in different includes then the include file will not be deleted.

    Arguments

  • Include label (integer)

    label of include file that you want to delete

  • method (optional) (constant)

    Method for deleting items. Must be Model.REMOVE_FROM_SETS (default), Model.REMOVE_JUNIOR or Model.REMOVE_INCLUDE_ONLY.
    Model.REMOVE_FROM_SETS will only delete items within the include selected but may remove items from sets in other includes.
    Model.REMOVE_JUNIOR may delete items in other includes - this will happen if they 'belong' to items in this include and are considered 'junior'
    Model.REMOVE_INCLUDE_ONLY does the same as Model.REMOVE_FROM_SETS but will not remove items from sets in other includes.

  • force (optional) (boolean)

    Forcible deletion option (for example, a node is deleted even when it is referenced by a shell which is not deleted). This will remove the include file (not just the contents) from the model. If this argument is omitted, force will be set to false.

    Returns

    true if include successfully deleted, false otherwise

    Return type

    Boolean

    Example

    To delete include file number 5 in model m removing items from sets in other includes if required:

    m.DeleteInclude(5, 1);


    FindElemEnd()   [deprecated]

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

    Tidy internal flag used by functions which find elements within a box. This function is only required if there has been a previous call to Model.FindElemInit() with a flag defined. This usage is deprecated for v20.0 where the flag should be applied in Beam.FindBeamInBox() Shell.FindShellInBox() Solid.FindSolidInBox() Tshell.FindTShellInBox() and there is no need to use FindElemInit or FindElemEnd

    Arguments

    No arguments

    Returns

    No return value

    Example

    m.FindElemEnd();


    FindElemInit(flag (optional)[Flag])   [deprecated]

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

    In v20.0 this function is obsolete. FindXXXInBox() is called without it. Refinement of element selection is now done with optional flagging argument in Beam.FindBeamInBox() Shell.FindShellInBox() Solid.FindSolidInBox() Tshell.FindTShellInBox() If you do use this function with flagging bit (not recommended), PRIMER copies flagging to another allocated flag, so you will need on completion to call FindElemEnd() to return this flag.

    Arguments

  • flag (optional) (Flag)

    Optional flag that has been set on the elements, if 0 all elements considered

    Returns

    No return value

    Example

    To initialize find setup for flagged elements in model m:

    m.FindElemInit(flag);


    First() [static]

    Description

    Returns the Model object for the first model in PRIMER (or null if there are no models)

    Arguments

    No arguments

    Returns

    Model object

    Return type

    Model

    Example

    To get the Model object for the first model:

    var m = Model.First();


    FirstFreeItemLabel(type[string], layer (optional)[Include number]) [static]

    Description

    Returns the first free label for an item type in the model. Also see Model.LastFreeItemLabel() and Model.NextFreeItemLabel().

    Arguments

  • type (string)

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

  • 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

    integer

    Return type

    Number

    Example

    To get the first free node label in model m:

    var label = m.FirstFreeItemLabel("NODE");


    FlagDuplicate(flag[Flag])

    Description

    Flag all nodes referenced in two different includes

    Arguments

  • flag (Flag)

    Flag which will be used to flag the "duplicate" nodes

    Returns

    No return value

    Example

    To Flag with flag f all the nodes referenced in different includes from model m

    m.FlagDuplicate(f);


    Flagged(flag[Flag])

    Description

    Checks if the model is flagged or not

    Arguments

  • flag (Flag)

    Flag to test on the model

    Returns

    true if flagged, false if not

    Return type

    Boolean

    Example

    To check if model m has flag f set on it:

    if (m.Flagged(f) ) do_something...


    GetAll() [static]

    Description

    Returns an array of Model objects for all the models in PRIMER

    Arguments

    No arguments

    Returns

    Array of Model objects

    Return type

    Array

    Example

    To make an array of Model objects for all of the models in PRIMER

    var m = Model.GetAll();


    GetFromID(model number[integer]) [static]

    Description

    Returns the Model object for a model ID or null if model does not exist

    Arguments

  • model number (integer)

    number of the model you want the Model object for

    Returns

    Model object

    Return type

    Model

    Example

    To get the Model object for model number 1

    var m = Model.GetFromID(1);


    GetIncludeTransformOffsets()

    Description

    Looks at all of the items in the model and determines values for IDNOFF, IDEOFF, IDPOFF etc that could be used with Model.ImportIncludeTransform to guarantee that there would not be any clashes with existing items in the model.

    Arguments

    No arguments

    Returns

    Object with the following properties:

    Name Type Description
    iddoff integer Offset to define id
    ideoff integer Offset to element id
    idfoff integer Offset to function id
    idmoff integer Offset to material id
    idnoff integer Offset to node id
    idpoff integer Offset to part id
    idroff integer Offset to section, hourglass, EOS id
    idsoff integer Offset to set id

    Return type

    object

    Example

    To determine offsets for model m and then import an include transform "test.inc":

    var o = m.GetIncludeTransformOffsets();
    if (o)
    {
        var success = m.ImportIncludeTransform("test.inc", o.idnoff, o.ideoff, o.idpoff, o.idmoff, o.idsoff, o.idfoff, o.iddoff, o.idroff);
    }


    Hide()

    Description

    Hides a model in PRIMER

    Arguments

    No arguments

    Returns

    No return value

    Example

    To hide model m in PRIMER

    m.Hide();


    Import(filename[string])

    Description

    Imports a file into model m. The model can already contain items. However, note that if the file cannot be imported because of a label clash or other problem PRIMER may delete the model and the script will terminate. Note prior to v17 of PRIMER imported data would always be imported to the master model, irrespective of the current layer. From v17 onwards this has been corrected and the current layer is used to determine the destination of imported data.

    Arguments

  • filename (string)

    Filename of the Ansys LS-DYNA keyword file you want to import

    Returns

    0: No errors/warnings.
    > 0: This number of errors occurred.
    < 0: Absolute number is the number of warnings that occurred.

    Return type

    Number

    Example

    To import file "test.key" into model m

    m.Import("test.key");


    ImportInclude(source[String OR Include Object], target (optional)[Include Object])

    Description

    Imports a keyword file or an Include object from different model as a new include or into an existing include file for model m. The labels of any items in the imported include contents that clash with existing labels will automatically be renumbered with one exception. The behaviour for *SET_COLLECT cards can be controlled with Options.merge_set_collect.

    Arguments

  • source (String OR Include Object)

    Can either be a Filename of the Ansys LS-DYNA include file you want to import, OR Include object of another model you want to import

  • target (optional) (Include Object)

    Include file object of current model if the Import has to be done in an existing include.
    If not using this argument the contents of the source will be imported as a new include.
    If using this argument the contents of the source will NOT be imported as a new include, they will be merged with the target include.
    Note: Target cannot be include number 0 (it must be an include file, not the master file)

    Returns

    Include object for include file

    Return type

    Include

    Example

    To import include file "include.key" into model m (include.key will be a new include file in model m):

    m.ImportInclude("include.key");

    To import include file "include.key" into existing include number 3 in model m (include.key will be merged with include number 3 of m):

    var incl_target = Include.GetFromID(m, 3);
    m.ImportInclude("include.key", incl_target);

    To import include number 5 from model m2 into model m1 (include number 5 from m2 will be a new include file in model m1):

    var incl_source = Include.GetFromID(m2, 5);
    m1.ImportInclude(incl_source);

    To import include number 5 from model m2 into existing include number 3 in model m1 (include number 5 from m2 will be merged with include number 3 in m1):

    var incl_source = Include.GetFromID(m2, 5);
    var incl_target = Include.GetFromID(m1, 3);
    m1.ImportInclude(incl_source, incl_target);


    ImportIncludeTransform(filename[string], idnoff[integer], ideoff[integer], idpoff[integer], idmoff[integer], idsoff[integer], idfoff[integer], iddoff[integer], idroff[integer])

    Description

    Imports a file as an include transform file for model m. The labels of any items in the include file will be renumbered by idnoff, ideoff etc.

    Arguments

  • filename (string)

    Filename of the Ansys LS-DYNA include file you want to import

  • idnoff (integer)

    Offset for nodes in the file

  • ideoff (integer)

    Offset for elements in the file

  • idpoff (integer)

    Offset for parts in the file

  • idmoff (integer)

    Offset for materials in the file

  • idsoff (integer)

    Offset for sets in the file

  • idfoff (integer)

    Offset for functions and tables in the file

  • iddoff (integer)

    Offset for defines in the file

  • idroff (integer)

    Offset for other labels in the file

    Returns

    Include object if successful, null if not

    Return type

    Include

    Example

    To import include transform file "include.key" into model m using 1000 for all offsets

    m.ImportIncludeTransform("include.key", 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000);


    Last() [static]

    Description

    Returns the Model object for the last model in PRIMER (or null if there are no models)

    Arguments

    No arguments

    Returns

    Model object

    Return type

    Model

    Example

    To get the Model object for the last model:

    var m = Model.Last();


    LastFreeItemLabel(type[string], layer (optional)[Include number]) [static]

    Description

    Returns the last free label for an item type in the model. Also see Model.FirstFreeItemLabel() and Model.NextFreeItemLabel().

    Arguments

  • type (string)

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

  • 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

    integer

    Return type

    Number

    Example

    To get the last free node label in model m:

    var label = m.LastFreeItemLabel("NODE");


    Mass()

    Description

    Returns the mass for a model

    Arguments

    No arguments

    Returns

    real

    Return type

    Number

    Example

    To get the mass for model m:

    var mass = m.Mass();


    MassPropCalc(flag[Flag])

    Description

    Calculates the Mass, CoG, and Intertia Tensor of the flagged items and returns an object with the above properties. See Properties for mass properties calculation under options class to configure inclusion of lumped mass, etc.

    Arguments

  • flag (Flag)

    Calculate mass propetries of flagged items

    Returns

    Object with the following properties:

    Name Type Description
    cofgx real X coordinate of centre of gravity
    cofgy real Y coordinate of centre of gravity
    cofgz real Z coordinate of centre of gravity
    inerxx real XX inertia
    inerxy real XY inertia
    inerxz real XZ inertia
    ineryy real YY inertia
    ineryz real YZ inertia
    inerzz real ZZ inertia
    mass real Mass

    Return type

    object

    Example

    To calculate the mass properties of the items flagged by flag f

    var props = m.MassPropCalc(f);


    Merge(Primary Model[Model], Secondary Model[Model], Option to fix clashes (optional)[constant], Merge nodes flag (optional)[boolean], dist (required if merge nodes flag used) (optional)[real], label (optional)[integer], position (optional)[integer]) [static]

    Description

    Merge 2 models together to make a new model.

    Arguments

  • Primary Model (Model)

    Primary Model for merge.

  • Secondary Model (Model)

    Secondary Model for merge.

  • Option to fix clashes (optional) (constant)

    Type of fix. Can be Model.INCREASE_SECONDARY_ALWAYS, Model.INCREASE_SECONDARY_CLASH, Model.DISCARD_SECONDARY_CLASH, Model.INCREASE_PRIMARY_ALWAYS, Model.INCREASE_PRIMARY_CLASH or Model.DISCARD_PRIMARY_CLASH

  • Merge nodes flag (optional) (boolean)

    If this flag is set to true, PRIMER will merge nodes after the model merge.

  • dist (required if merge nodes flag used) (optional) (real)

    Nodes closer than dist will be potentially merged.

  • label (optional) (integer)

    Label to keep after merge. If > 0 then highest label kept. If <= 0 then lowest kept. If omitted the lowest label will be kept.

  • position (optional) (integer)

    Position to merge at. If > 0 then merged at highest label position. If < 0 then merged at lowest label position. If 0 then merged at midpoint. If omitted the merge will be done at the lowest label.

    Returns

    Model object (or null if the merge is unsuccessful)

    Return type

    Model

    Example

    To merge models m1 and m2 together:

    var m = Model.Merge(m1, m2);


    MergeNodes(flag[Flag], dist[real], label (optional)[integer], position (optional)[integer])

    Description

    Attempts to merge nodes on items flagged with flag for this model in PRIMER. Merging nodes on *AIRBAG_SHELL_REFERENCE_GEOMETRY can be controlled by using Options.node_replace_asrg. Also see Node.Merge().

    Arguments

  • flag (Flag)

    Flag set on items to merge nodes

  • dist (real)

    Nodes closer than dist will be potentially merged.

  • label (optional) (integer)

    Label to keep after merge. If > 0 then highest label kept. If <= 0 then lowest kept. If omitted the lowest label will be kept.

  • position (optional) (integer)

    Position to merge at. If > 0 then merged at highest label position. If < 0 then merged at lowest label position. If 0 then merged at midpoint. If omitted the merge will be done at the lowest label.

    Returns

    The number of nodes merged

    Return type

    Number

    Example

    To (try to) merge nodes on everything in model m flagged with flag f, with a distance of 0.1:

    m.MergeNodes(f, 0.1);


    NextFreeItemLabel(type[string], layer (optional)[Include number]) [static]

    Description

    Returns the next free label for an item type in the model. Also see Model.FirstFreeItemLabel() and Model.LastFreeItemLabel().

    Arguments

  • type (string)

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

  • 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

    integer

    Return type

    Number

    Example

    To get the next free node label in model m:

    var label = m.NextFreeItemLabel("NODE");


    PopulateInitialVelocities()

    Description

    Populate the initial velocity field (nvels) for all nodes of the model

    Arguments

    No arguments

    Returns

    No return value

    Example

    m.PopulateInitialVelocities();


    PropagateFlag(flag[Flag])

    Description

    Propagates the flagging for a model in PRIMER. For example if a part in the model is flagged, this will flag the elements in the part, the nodes on those elements... See also Model.ClearFlag(), Model.SetFlag(), global.AllocateFlag() and global.ReturnFlag().

    Arguments

  • flag (Flag)

    Flag to propagate

    Returns

    No return value

    Example

    To propagate the flagging in model m for flag f

    m.PropagateFlag(f);


    Read(filename[string], filetype (optional)[constant], number (optional)[integer]) [static]

    Description

    Reads a file into the first free model in PRIMER

    Arguments

  • filename (string)

    Filename you want to read

  • filetype (optional) (constant)

    Filetype you want to read. Can be Model.LSDYNA, Model.ABAQUS, Model.NASTRAN, Model.RADIOSS or Model.IGES. If omitted the file is assumed to be a DYNA3D file. For Model.NASTRAN there are options that change how the model is read. See Options for details.

  • number (optional) (integer)

    Model number to read file into. If omitted the next free model number will be used.

    Returns

    Model object (or null if error)

    Return type

    Model

    Example

    To read the keyword file /data/test/file.key

    Model.Read("/data/test/file.key");

    To read the NASTRAN file /data/test/file.dat

    Model.Read("/data/test/file.dat", Model.NASTRAN);

    To read the keyword file /data/test/file.key into model 10

    Model.Read("/data/test/file.key", Model.LSDYNA, 10);


    RenumberAll(start[integer])

    Description

    Renumbers all of the items in the model.

    Arguments

  • start (integer)

    Start point for renumbering

    Returns

    No return value

    Example

    To renumber everything in model m, starting at 1000000:

    m.RenumberAll(1000000);


    RenumberFlagged(flag[Flag], start[integer], mode (optional)[constant])

    Description

    Renumbers all of the flagged items in the model.

    Arguments

  • flag (Flag)

    Flag set on items that you want to renumber

  • start (integer)

    Start point for renumbering

  • mode (optional) (constant)

    Renumber mode. Can be Model.IGNORE_CLASH, Model.MOVE_CLASH_UP, Model.SHIFT_ALL_UP, or Model.RENUMBER_TO_FREE (default),

    Returns

    No return value

    Example

    To renumber everything in model m flagged with flag f, starting at 1000000, using mode MOVE_CLASH_UP:

    m.RenumberFlagged(f, 1000000, Model.MOVE_CLASH_UP);


    Select(prompt[string], modal (optional)[boolean]) [static]

    Description

    Allows the user to select a model using standard PRIMER object menus. If there are no models in memory then Select returns null. If only one model is present then the model object is returned. If there is more than one model in memory then an object menu is mapped allowing the user to choose a model.

    Arguments

  • prompt (string)

    Text to display as a prompt to the user

  • 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

    Model object (or null if no models present).

    Return type

    Model

    Example

    To select a model giving the prompt 'Select model':

    var m = Model.Select('Select model');


    SetColour(colour[colour from Colour class.])

    Description

    Sets the colour of the model.

    Arguments

  • colour (colour from Colour class.)

    The colour you want to set the model to

    Returns

    No return value

    Example

    To set the colour of model m to red:

    m.SetColour(Colour.RED);

    or

    m.SetColour(Colour.RGB(255, 0, 0));


    SetFlag(flag[Flag])

    Description

    Sets the flagging for a model in PRIMER. See also Model.PropagateFlag(), Model.ClearFlag(), global.AllocateFlag() and global.ReturnFlag().

    Arguments

  • flag (Flag)

    Flag to set

    Returns

    No return value

    Example

    To set flag f for everything in model m:

    m.SetFlag(f);


    Show()

    Description

    Shows a model in PRIMER

    Arguments

    No arguments

    Returns

    No return value

    Example

    To show model m in PRIMER

    m.Show();


    Total() [static]

    Description

    Returns the total number of models.

    Arguments

    No arguments

    Returns

    integer

    Return type

    Number

    Example

    To find how many models there are in PRIMER:

    var num = Model.Total();


    Unblank()

    Description

    Unblanks a model in PRIMER

    Arguments

    No arguments

    Returns

    No return value

    Example

    To unblank model m

    m.Unblank();


    UnblankAll() [static]

    Description

    Unblanks all models

    Arguments

    No arguments

    Returns

    No return value

    Example

    To unblank all models

    Model.UnblankAll();


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

    Description

    Unblanks all of the flagged items in the model.

    Arguments

  • flag (Flag)

    Flag set on items 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 everything in model m flagged with flag f:

    m.UnblankFlagged(f);


    UnsketchAll(redraw (optional)[boolean])

    Description

    Unsketches all of the sketched items in the model.

    Arguments

  • redraw (optional) (boolean)

    If model should be redrawn or not after the items 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 the sketched objects in model m:

    m.UnsketchAll();


    UpdateGraphics()

    Description

    Updates the graphics for a model in PRIMER

    Arguments

    No arguments

    Returns

    No return value

    Example

    To update the graphics for model m

    m.UpdateGraphics();


    UsesLargeLabels()

    Description

    Checks to see if a model uses large labels

    Arguments

    No arguments

    Returns

    logical, true if model uses large labels, false otherwise

    Return type

    Boolean

    Example

    To check if model m uses large labels:

    var large = m.UsesLargeLabels();


    Write(filename[string], options (optional)[object])

    Description

    Writes a model in PRIMER to file

    Arguments

  • filename (string)

    Filename of the Ansys LS-DYNA keyword file you want to write

  • options (optional) (object)

    Options specifying how the file should be written out. If omitted the default values below will be used. The properties available are:

    Object has the following properties:

    Name Type Description
    binary (optional) boolean If true then the entire output file will be written out in binary, if false then the entire file will be written in ascii. If not defined the default is for each file in the model to be written in its original format, or if this is a newly created model ascii will be used.
    compress (optional) boolean If true then the output file will be compressed. If false (default) then an uncompressed file will be written.
    compressLevel (optional) integer Compression level for .gz and .zip files. Must be in the range 1 to 9 with 1 being the least compression (fastest speed) to 9 being the greatest compression (slowest speed)
    compressMode (optional) integer This option can be used to specify the mode of compression. Can be Include.KEEP_ORIGINAL or Include.INDIVIDUAL_GZIP or Include.INDIVIDUAL_ZIP
    fileStartAscii (optional) boolean Only relevant if binary output format has been selected. If true then the beginning of the file (*CONTROL etc) file is written out in ascii. If false (default) then the entire file is converted to binary.
    i10 (optional) boolean If true then i10 format will be used to write the file. If false (default) then the original Ansys LS-DYNA format in which the file was written will be used, or if this is a newly created model the smallest format which will contain it will be used. Note that large format is only available from version R9 and above. See also the large property.
    kbyExt (optional) boolean If true then a binary format output file will be given the extension .kby, replacing the existing extension.
    large (optional) boolean If true then large format will be used to write the file. If false (default) then the normal Ansys LS-DYNA format will be used. Note that large format is only available from version R7.1 and above.
    masterAscii (optional) boolean Only relevant if binary output format has been selected. If true then the whole master file is written out in ascii. If false (default) then the master file is also converted to binary.
    method (optional) integer The method used to write include files. Can be Include.MASTER_ONLY, Include.MERGE, Include.NOT_WRITTEN, Include.SUBDIR (default) or Include.SAME_DIR
    parametersAsValues (optional) boolean If true then the underlying values of any parameters will be written when they are used in data fields rather than '&name'. If false then '&name' will be written. See also Options.keyout_parameter_values
    path (optional) integer The method used to write include paths. Can be Include.ABSOLUTE (default) or Include.RELATIVE
    separator (optional) integer The directory separator used when writing include files. Can be Include.NATIVE (default), Include.UNIX or Include.WINDOWS
    version (optional) string The Ansys LS-DYNA version used to write the file. Can be "971R5", "971R4", "971R3", "970v6763" etc (see the version popup in Model->Write '>>> Ansys LS-DYNA output options' for a full list). See also Options.dyna_version

    Returns

    No return value

    Example

    To Write model m to file /data/test/file.key as a compressed gzip in version R10.0

     var output_obj = new Object();
     output_obj.version = "R10.0";
     output_obj.compress = true;
     output_obj.compressMode = Model.INDIVIDUAL_GZIP;
     m.Write("/data/test/file.key", output_obj);


    Write(filename[string], method (optional)[constant], path (optional)[constant], separator (optional)[constant], version (optional)[string], large (optional)[boolean])   [deprecated]

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

    Writes a model in PRIMER to file

    Arguments

  • filename (string)

    Filename of the Ansys LS-DYNA keyword file you want to write

  • method (optional) (constant)

    The method used to write include files. Can be Include.MASTER_ONLY, Include.MERGE, Include.NOT_WRITTEN, Include.SUBDIR (default) or Include.SAME_DIR

  • path (optional) (constant)

    The method used to write include paths. Can be Include.ABSOLUTE (default) or Include.RELATIVE

  • separator (optional) (constant)

    The directory separator used when writing include files. Can be Include.NATIVE (default), Include.UNIX or Include.WINDOWS

  • version (optional) (string)

    The Ansys LS-DYNA version used to write the file. Can be "971R5", "971R4", "971R3", "970v6763" etc (see the version popup in Model->Write '>>> Ansys LS-DYNA output options' for a full list). See also Options.dyna_version

  • large (optional) (boolean)

    If true then large format will be used to write the file. If false (default) then the original Ansys LS-DYNA format in which the file was written will be used, or if this is a newly created model the smallest format which will contain it will be used. Note that large format is only available from version R7.1 and above. See also the i10 property.

    Returns

    No return value

    Example

    To Write model m to file /data/test/file.key

    m.Write("/data/test/file.key");