mdlIObject ReplaceEntity

Replaces an existing entity with a new entity using the class variable name from the MDF file.

Syntax

mdlIObject_handle ReplaceEntitynew_handle, old_handle, class_var, varname, is_pair

Application

MotionView Tcl Modify

Description

This command replaces an existing entity with a new entity using the class variable name from the MDF file.
Note: You can only specify the entity type, the variable name, and whether or not the new entity is a single or a pair. Only an entity can be replaced by this process.

Inputs

new_handle
The handle for the new entity.
old_handle
The handle of the current entity. The new entity handle replaces the old handle.
class_var
For example the class variables are:
"body_ent"
For body class
"vector_ent"
For vector class
"graphic_ent"
For graphic class.
In general it is "entitytype_ent".
You can also find the class_var by searching and opening the topology_writer.mdf file.
varname
The local variable name and default label for the new entity.
is_pair
The Boolean flag that is used to determine if the entity is created as a single or a pair.

Example

To replace the old body with a new body:
hwi OpenStack
hwi GetSessionHandle mySessionName 
mySessionName GetProjectHandle myProjectName 
set activePageNum [myProjectName GetActivePage]
myProjectName GetPageHandle myPageName $activePageNum
set activeWinNum [myPageName GetActiveWindow]
myPageName GetWindowHandle myWindowName $activeWinNum
myWindowName GetClientHandle myClientName 
myClientName GetModelHandle myModelName 
myModelName BeginFlatListFastGet "body"
myModelName GetChildHandleByIdx mybody 2
myModelName ReplaceEntity newbody mybody body_ent body_new false
myModelName EndChildFastGet
newbody ReleaseHandle
myModelName ReleaseHandle
myClientName ReleaseHandle
myWindowName ReleaseHandle
myPageName ReleaseHandle
myProjectName ReleaseHandle
mySessionName ReleaseHandle
hwi CloseStack

Error

Returns 0 if successful, otherwise an error code.

or

Returns the name of the new_handle (in the example above it returns "newbody").