CreateCopy(OpenForEdit: Boolean): ICalcObject;
OpenForEdit. Allow or deny to edit calculation algorithm object.
The CreateCopy method creates a copy of calculation algorithm object.
Available values of the OpenForEdit parameter:
True. Editing of calculation algorithm is available.
False. Editing of calculation algorithm is not available.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. The calculation algorithm should contain configured objects.
Add links to the Algo system assembly. Add a link to the assembly required for working with calculation algorithm.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObjectDescriptor;
CalcAlgo: ICalcAlgorithm;
Objects: ICalcObjectsList;
Algo, CalcAlgObj, CopyObj: ICalcObject;
Begin
MB := MetabaseClass.Active;
// Get calculation algorithm
MObj := MB.ItemById("ALGORITHM");
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
CalcAlgo := Algo As ICalcAlgorithm;
// Create a copy of the first block
Objects := CalcAlgo.Items;
CalcAlgObj := Objects.Item(0);
CopyObj := CalcAlgObj.CreateCopy(True);
CopyObj.Name := "Block copy";
Objects.Add(CopyObj);
// Save changes
CopyObj.SaveObject;
Algo.SaveObject;
End Sub UserProc;
After executing the example, a copy of the first existing object will be created in the calculation algorithm.
See also: