mdlIObject GetNumberOfChildren
Gets the number of child objects under a particular entity type.
Syntax
mdlIObject_handle GetNumberOfChildren or set num[mdlIObject_handle GetNumberOfChildren]
Application
MotionView Tcl Query
Description
This command obtains the number of child objects under a particular entity type.
Example
To find the number of bodies in the
model:
hwi OpenStack
hwi GetSessionHandle sess1
sess1 GetProjectHandle pro1
pro1 GetPageHandle pa1 [pro1 GetActivePage]
pa1 GetWindowHandle win1 [pa1 GetActiveWindow]
win1 GetClientHandle mc1
mc1 GetModelHandle mod1
mod1 BeginFlatListFastGet Body
set num_body [mod1 GetNumberOfChildren]
set idx [mod1 GetChildHandleByIdx ch_b1 1]
mod1 GetChildHandle bchld [ch_b1 GetVarname]
bchld GetChildHandle bms mass
set body_mass [bms GetEvaluatedValue];
set new_mass [expr $body_mass + 10];
bms SetRawExpression $new_mass
bms Evaluate;
mod1 Evaluate;
mod1 EndChildFastGet
bms ReleaseHandle;
bchld ReleaseHandle;
mod1 ReleaseHandle;
mc1 ReleaseHandle;
win1 ReleaseHandle;
pa1 ReleaseHandle;
pro1 ReleaseHandle;
sess1 ReleaseHandle;
hwi CloseStack;
Errors
Returns a non-negative integer value (the number of child objects).