Get child elements of a model
Get child elements owned by the model.
public void GetChildren(ICommandContext c, ICommandParams p)
{
var children = c.App.Workspace.CurrentModel.GetChildren();
//Print the names of the children in the output tab of the info window
foreach ( var child in children )
{
c.App.Output.WriteLine("sample",child.Name);
}
}
Get all descendant elements owned by the model.
public void GetAllChildren(ICommandContext c, ICommandParams p)
{
//Get all descendant elements of the main editor's model
var children = c.App.Workspace.CurrentModel.GetAllChildren();
//...
}
To get all models of a project, call the GetAllChildren
method on the IProject
object.
public void GetAllChildren(ICommandContext c, ICommandParams p)
{
//Get all descendant elements of a project
var children = c.App.Workspace.CurrentProject.GetAllChildren();
//...
}