AttachModel

From GECK
Jump to: navigation, search


A function added by the JIP NVSE Plugin.

Description

Attaches a complete copy of a model from a selected NIF file to an existing NiNode in the 3D model of the specified object form.

The function takes 3(+) arguments, as follows:

  • refOrForm - Either an object reference or a base form. In the former case, the model will be attached to the target node in the 3D model of that specific reference only, whereas in the latter case, it will be attached in the 3D model of any reference instance of the base form.
  • addOrRemove - Either attach, or remove a previously attached model. Use one of the following values:
0	Remove; Pending reload
1	Attach; Pending reload
2	Remove; Instantaneous
3	Attach; Instantaneous
  • Pending reload - Changes will be applied once either the object's 3D is (re)loaded by the game, or Update3D is called on it.
  • Instantaneous - Changes will be applied instantly.
  • targetAndFile - A formatted string containing the name (case-sensitive) of an existing NiNode in the object's 3D model and, separated by a vertical bar "|", the path of the NIF file containing the model (NOT case-sensitive). Note that the path must be relative to ..\Data\Meshes\
  • Block name suffixes - The function can optionally append a suffix to the name of every block in the attached NIF. This is useful when attaching multiple copies of the same NIF to a model, and/or for avoiding an outcome where the model contains multiple blocks with the same name (which may cause various issues). Suffixes have a character limit of 15.
To specify a suffix, add the suffix string immediately before the NIF path, enclosed by asterisks. For example: "Bip01 R Thigh|*_CPY1*weapons\9mmSMG.nif".

Syntax

[help]
(successful:0/1) AttachModel refOrForm:form addOrRemove:int{0-3} targetAndFile:formattedString formatVars(up to 20)

Example

AttachModel PlayerRef 3 "Bip01 Head|*_SNIG*clutter\junk\tincan01.nif"

The above will instantly ATTACH a copy of tincan01.nif, with the suffix "_SNIG" appended to every block name, to the "Bip01 Head" node in the 3D model of the PlayerRef.

AttachModel PlayerRef 2 "Bip01 Head|*_SNIG*clutter\junk\tincan01.nif"

The reverse of previous example. This will instantly REMOVE tincan01.nif, with the suffix "_SNIG", from the "Bip01 Head" node.

AttachModel HoneyMesquitePickable 1 "NVHoneyMesquite|clutter\food\vodka01.nif"

The above will ATTACH a copy of vodka01.nif to the "NVHoneyMesquite" node in the 3D model of every instance of HoneyMesquitePickable.

AttachModel HoneyMesquitePickable 0 "NVHoneyMesquite|clutter\food\vodka01.nif"

The reverse of previous example.

Notes

  • Any changes made by this function remain in effect for the duration of the current game session, or until removed.
  • On successful insertion, the function returns 1, otherwise 0.
  • Using InsertNode/AttachModel on dynamic refs will only work with mode 3. For instantaneous removal of attached nodes/models from temporary refs, you'll need to use RemoveNifBlock.

See Also