CopyModelSpace Command

Purpose

It copies modeling container.

Parameters of Use

Command parameters are passed in the IUiCommandExecutionContext.Data property. Executing the command requires to specify the following value in this property:

Value type Description
IMetabaseObjectCopyInfo Object with parameters of copying the Modeling Container repository object.

Application Features

The command can be applied only to modeling container.

Example

Executing the example requires a form containing a button with the Button1 identifier.

It is required that the repository contains a modeling container with the MS_PLUGIN identifier.

Add links to the Fore, Metabase, Ms, UI system assemblies.

The example is a handler of the OnClick event for the Button1 button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Mb: IMetabase;
    CInfo: IMetabaseObjectCopyInfo;
    Target: IUiCommandTarget;
    Context: IUiCommandExecutionContext;
Begin
    
// Get current repository
    Mb := MetabaseClass.Active;
    
// Create an object to copy and set parameters
    CInfo := MB.CreateCopyInfo;
    CInfo.Id := MB.GenerateId(
"MS_PLUGIN_COPY");
    CInfo.Name := 
"Container copy";
    CInfo.WithData := 
True;
    CInfo.Source := MB.ItemById(
"MS_PLUGIN");
    CInfo.Destination := MB.Root;
    
// Get the Ms plugin
    Target := WinApplication.Instance.GetPluginTarget("Ms");
    
// Create a context to execute a command
    Context := Target.CreateExecutionContext;
    
// Send command parameter
    Context.Data := CInfo;
    
// Execute the command
    Target.Execute("CopyModelSpace", Context);
End Sub Button1OnClick;

After executing the example, clicking the Button1 copies the modeling container with data.

See also:

IUiCommandTarget.Execute