What's New in Director 8.5 > Working with Models and Model Resources > Cast member commands |  |

Cast member commands

If the models and model resources you need aren't contained in a particular cast member, the following commands allow you to create models and model resources using other 3D cast members at run time.

Command | Description | Returns
--- | --- | ---
`loadFile(``fileName,Overwrite, GenerateUniqueNames``)` | This command loads a W3D format file from `fileName`, adds all models as children of the world, and updates all palettes. You can call this function only if the cast member's state property is either `-1`, meaning that an error occurred during a previous attempt to load the file, or `4`, meaning that media loading is complete. If an attempt is made to call `loadFile` while the cast member is streaming media in, a Lingo error is generated.

`Overwrite` is an optional variable that can be `TRUE (1)` or `FALSE (0)`:

`TRUE (1)` means the old world is replaced by the contents of the file.

`FALSE (0)` means the new file is merged into the existing world.

`GenerateUniqueNames` is a variable that has no meaning unless `Overwrite` is `FALSE (0)`.

If `Overwrite` is `FALSE (0)`, then if`GenerateUniqueNames` is `TRUE (1)`, all new elements sharing the same name as existing elements are assigned a new, algorithmically determined unique name.

If `GenerateUniqueNames` is `FALSE (0)`, all existing elements sharing the same name as new elements being read into the file are replaced by the new elements.

Nothing if the operation is successful, or a Lingo error if the operation fails

`cloneModelFromCastmember(``name, model,castmember``)` | Performs a deep clone of a model from one cast member and puts it into another cast member. The model, its resources, its children, and its children's resources all are put into the new cast member. | A model object
cloneMotionFromCastMember(`name`, `motion`, `castmember`) | Performs a deep clone of a motion from one cast member and puts it into another cast member. | A motion object
`newModelResource(``name,type)` | Creates a new model resource and adds it to the model resource palette. The `type` can be `#plane`, `#box`, `#sphere`, `#cylinder`, or `#particle`. The `type` cannot be `#mesh`. To create a new mesh model resource, use the `newMesh` command detailed below. | New model resource object
`newMesh(``name,numFaces, numVertices, numNormalsnumColors,numTextureCoordinates``)` | Creates a new mesh model resource. `numFaces` is the user-specified number of triangles. `numVertices` is the user-specified number of vertices. A vertex can be used by more than one face. `numNormals` is the user-specified number of normals. Enter `0` or omit this step to use the `generateNormals()` method.

`numColors` is the user-specified number of colors. You can specify a color for each point of a triangle.

`numTextureCoordinates` is the number of user-specified texture coordinates. Enter `0` or omit this step to get the default coordinates.

New mesh model resource